variable with space 
Author Message
 variable with space


Quote:
> Hello everybody,

> I have some lines like theses:

> dddddd fffffffff ggggggg
> dddddd fffffffff ggggggg
> dddddd fffffffff ggggggg
> ddddddd ssssssss

> and so on!

> I want to have a variable with all the lines, like
> var1="dddddd fffffffff ggggggg"
> var2="dddddd fffffffff ggggggg"
> var3="dddddd"

> and so on, whithout knowing how will be the next line.

Assume lines in a file called, 'myFile'. So, try:

    awk '{ print "var" NR "=\"" $0 "\""; }' myFile

I hope this helps.



Sun, 10 Aug 2003 05:45:37 GMT  
 variable with space
$0 is the current line as is with all the spaces.
Hence you could have
    { lines[NR] = $0
as your program and process the variables lines[I] in the END section

The above is just an illustration and may not be exactly what your desired
solution but I hope it will help

By the way there are excellent documentation out in the web. If you can get
hold of the PDF version such as MKS for awk, life can be easier.  Of course
you can stick with your man pages on awk on your computer..


Quote:


> > Hello everybody,

> > I have some lines like theses:

> > dddddd fffffffff ggggggg
> > dddddd fffffffff ggggggg
> > dddddd fffffffff ggggggg
> > ddddddd ssssssss

> > and so on!

> > I want to have a variable with all the lines, like
> > var1="dddddd fffffffff ggggggg"
> > var2="dddddd fffffffff ggggggg"
> > var3="dddddd"

> > and so on, whithout knowing how will be the next line.

> Assume lines in a file called, 'myFile'. So, try:

>     awk '{ print "var" NR "=\"" $0 "\""; }' myFile

> I hope this helps.



Mon, 11 Aug 2003 08:24:32 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. variables with space causes errormessages?!

2. textfield and variables with spaces

3. Global variables at the Address Space level

4. variable with many space

5. Variables with *WHITE SPACE*..

6. removing trailing spaces from string variables

7. Help: how to make a space into a variable

8. delelting space if it's one space

9. replace substring by spaces - taking same space as substring

10. Replace spaces with single space

11. Code space and data space

12. Problem space and solution space

 

 
Powered by phpBB® Forum Software