kornShellScripter
Programmer
Hi,
I'm using ksh and am analysing reports which have fixed column widths (candidate for the cut command).
The values in that particular column might not be as wide as the column, so
might set
and what I want is
(so I want to strip the trailing spaces)
So far, the best I've come up with is either
which is neat and VALUE ends up with precicely what I want, but it uses an external (sed)
or
which keeps things within the shell, but is ugly
Any ideas improving on the above?
I'm using ksh and am analysing reports which have fixed column widths (candidate for the cut command).
The values in that particular column might not be as wide as the column, so
Code:
VALUE=$(cut -c10-25 file)
Code:
VALUE="GB 123 ABC G "
Code:
VALUE="GB 123 ABC G"
So far, the best I've come up with is either
Code:
VALUE=$(cut -c5-10 file | sed 's/ *$//')
or
Code:
VALUE=$(cut -c5-10 file) ; VALUE=${VALUE%% *}
Any ideas improving on the above?