[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: awk or sed
From: |
ali hagigat |
Subject: |
Re: awk or sed |
Date: |
Sat, 23 Apr 2011 11:07:06 +0430 |
I have a makefile and I want to print each word of the variable, .VARIABLES
on a separate line.
This is the content of .VARIABLES:
.VARIABLES=<D ?F CCACHE_DIR DESKTOP_SESSION CWEAVE ?D GTK_RC_FILES @D
XAUTHORITY GDMSESSION XMODIFIERS CURDIR SHELL RM GDM_LANG _ PREPROCESS.F
var2 LINK.o OUTPUT_OPTION COMPILE.cpp MAKEFILE_LIST @F HISTCONTROL USERNAME
...........................
It was long and I did not copy the rest of the lines.
It seems that the previous simple solution of Mr. Johnson here does not
work, means: printf "%s\n" $var
On Wed, Apr 6, 2011 at 7:47 AM, Chris F.A. Johnson <chris@cfajohnson.com>wrote:
> On Wed, 6 Apr 2011, 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.
>>
>
> printf "%s\n" $var1
>
> (You might want to precede that with 'set -f'.)
>
> --
> Chris F.A. Johnson, <http://cfajohnson.com/>
> Author:
> Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
>