On 4/5/2011 11:09 PM, ali hagigat wrote:
I have a variable like this: var1=Makefile .xcompile /root/build/.config src/arch/i386/Makefile.inc means some words separated by spaces. I want to print each word on a separate line. I think I have to use "awk" or "sed" string processing tools. I wonder if anybody have experience with them or any other means to do it.
Neither: var1='Makefile .xcompile /root/build/.config src/arch/i386/Makefile.inc' v2=($var1) # Now v2 is an array with the elements delimited by IFS IFS=$'\n' # Change IFS to newlines and use it as the separator # when expanding using [@] echo "${v2[*]}" Easy peasy. -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net