get leading spaces into EnvVar

Hi!

this all in ksh!!!

think of something like
...|cut -f8- -d";"
now I want something like
...|cut -f8- -d";"|read XYZ
echo "$XYZ"

The problem is, that leading spaces are ignored by "read"!
What read does wrong, export does right!

export XYZ="     123"
echo "$XYZ"
     123

So I want to pipe into export!
How can I solve this??

Thanks
Witty

LVL 1
wittyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tfewsterCommented:
How about XYZ=`...|cut -f8- -d";"` ?
0
mliberiCommented:
read uses IFS environment variable to tokenize input lines. So just set IFS to the empty string before reading.

example:
IFSsave=$IFS    # save IFS value
.... | read XYZ
IFS=$IFSsave    # restore saved value

You may also want to ignore special sequences, such as \n \t \r etc., using '-r' (raw read) option.

enjoy.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mliberiCommented:
you could also use the following syntax instead of using 'read'

XYZ="$(...|cut ...)"
0
wittyAuthor Commented:
mliberi,

cool, this was exactly, what I needed!!!

Thank you VERY much
Michael
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.