Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Andy Lennard — — source: Usenet: comp.databases.informix
In message <c703eed2.0306190725.c49721a@posting.google.com>, JeffC
<gninnacj@netscape.net> writes
>Hi,
>
>When using the following the trailing spaces are not removed from
>the string. Why does this not work properly?
>
>$ userid=$(echo "select trim(trailing ' ' from userid) as userid from
>table where userid = 'a1abcdef'" | dbaccess $DB 2>/dev/null | grep -vi
>user | sort -nr)
>$ echo "[${userid}]"
>[a1abcdef ]
> ^^^^>The spaces have not been trimmed in the result.
>
>Regards,
>Jeff
I guess it's because dbaccess is trying to pretty-print the output and
line up the text under the column headings. The 'trim' is working OK,
it's just that spaces are getting added later when the data is output.
I think that if you want to avoid this you need to use 'unload', as
'output to pipe cat select...' exhibits the same behaviour.
Or if you're using ksh (or similar) echo "[${userid%%+( )}]"
--
Andrew Lennard andy@kontron.demon.co.uk
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.