bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: awk or sed


From: Steven W. Orr
Subject: Re: awk or sed
Date: Wed, 06 Apr 2011 09:30:11 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9

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 address@hidden
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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]