Home > Archive > AWK > April 2005 > return each elemet from one input line with a newline
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
return each elemet from one input line with a newline
|
|
| joerg mauz 2005-04-28, 3:57 pm |
| hi all,
is there a way to create an awk script that can handle the follwing task:
i got one line (it's my unix/windows PATH variable) that has a delimiter
(":") between each element:
/cygdrive/d/program files/app1:/usr/bin:/sth/else:
what i need to have now is a script that returns me the following
/cygdrive/d/program files/app1
/usr/bin
/sth/else
so that each element is printed in a seperat row. but mention that there
might be blanks ("/cygdrive/d/program files/app1")
within my elements..
thanks in advance
cheers
joerg
| |
| Loki Harfagr 2005-04-28, 3:57 pm |
| Le Thu, 28 Apr 2005 19:05:07 +0200, joerg mauz a écrit_:
> hi all,
>
> is there a way to create an awk script that can handle the follwing task:
>
> i got one line (it's my unix/windows PATH variable) that has a delimiter
> (":") between each element:
>
> /cygdrive/d/program files/app1:/usr/bin:/sth/else:
>
> what i need to have now is a script that returns me the following
>
> /cygdrive/d/program files/app1
> /usr/bin
> /sth/else
>
> so that each element is printed in a seperat row. but mention that there
> might be blanks ("/cygdrive/d/program files/app1")
> within my elements..
>
> thanks in advance
>
> cheers
> joerg
Just use RS properly :
$ echo "/cygdrive/d/program files/app1:/usr/bin:/sth/else:" | awk
'{print}' RS=":" /cygdrive/d/program files/app1
/usr/bin
/sth/else
$ echo "/cygdrive/d/program files/app1:/usr/bin:/sth/else:" | awk '1' RS=":"
/cygdrive/d/program files/app1
/usr/bin
/sth/else
| |
| joerg mauz 2005-04-28, 3:57 pm |
| it works !
thanks very much !!!
|
|
|
|
|