printf("%s%s%s%s%s%s%s",$1,$2,$3,$4..... ?

printf("%s%s%s%s%s%s%s",$1,$2,$3,$4..... ?

Post by Z-ma » Wed, 12 Jul 1995 04:00:00



How can I print the rest of the line using awk?

I have:

awk -F" " '{printf("%s\n")}' file

in the middle of this long pipe. I can't use cut -d" " -f2- because
some of the input lines start with a space, and then the fields shift
over. This doesn't happen with awk.

The input file is like this:

I want
not this| but this
-------- ---------------------------------
24312431 this does this blah ablha
14233422 ahve a nice day
24323423 go to asfd asfd asfd sdf dsf sfd.
24334243 this doesn't work blaha balha

without having to specify a millin $2,$3,$4......

Do I have to learn perl now? ;)

 
 
 

printf("%s%s%s%s%s%s%s",$1,$2,$3,$4..... ?

Post by Christopher Blenco » Wed, 12 Jul 1995 04:00:00


Well, I guess it will go this way (ONE solution)

{
sub("^ *","")
sub("^" $1 ,"")
sub("^ *","")
print

Quote:}

You may or may not use three sub's the second is essential,
the first and third depend on your FS string

Sincerly Christopher

: How can I print the rest of the line using awk?

: I have:

: awk -F" " '{printf("%s\n")}' file

: in the middle of this long pipe. I can't use cut -d" " -f2- because
: some of the input lines start with a space, and then the fields shift
: over. This doesn't happen with awk.

: The input file is like this:

: I want
: not this| but this
: -------- ---------------------------------
: 24312431 this does this blah ablha
: 14233422 ahve a nice day
: 24323423 go to asfd asfd asfd sdf dsf sfd.
: 24334243 this doesn't work blaha balha
:  
: without having to specify a millin $2,$3,$4......

: Do I have to learn perl now? ;)

--
----------------------------------------------------------------------

>                    Christopher Blencowe             _______     <
>>         ||     Pharmazeutisch-Chemisches Institut      | .._.. |   <<
>>>    /  \          Universitaet Heidelberg           |_______|  <<<
>>     /____\                   GERMANY                   /______/    <<


----------------------------------------------------------------------

 
 
 

printf("%s%s%s%s%s%s%s",$1,$2,$3,$4..... ?

Post by Zefr » Fri, 14 Jul 1995 04:00:00



>in the middle of this long pipe. I can't use cut -d" " -f2- because
>some of the input lines start with a space, and then the fields shift
>over. This doesn't happen with awk.

>The input file is like this:

>I want
>not this| but this
>-------- ---------------------------------
>24312431 this does this blah ablha
>14233422 ahve a nice day
>24323423 go to asfd asfd asfd sdf dsf sfd.
>24334243 this doesn't work blaha balha

sed 's/^ *[^ ]* *//'

-zefram

 
 
 

1. detecting no command line parms as $1,$2,$3 etc...

How do i test to see if a variable is blank or empty like the command line
parameter.
When I attempt to do:
    ELMO=$1
    if [ ${ELMO}="" ]; then
        echo "Enter something on command line you dope"
        exit 1
    fi
    echo "Man you are ${ELMO}"

It always either skips the if statement all together or ALWAYS evaluates to
true. is there something i am missing? I have tried several variations, " "
or "", they both evaluate to always true or false respectively.

cheers,
elmo

--

Emilio M Recio
Office Of Information Technology
Thomas Jefferson University

2. Diamond video cards running X?

3. sh says: test "$1" = "" when $1="-b"

4. GDM Login

5. cut | awk (sum $1,$2)

6. Recoving space from deleted file

7. awk question: how to shift $1, $2, etc

8. [patch] Adding Transmit load balancing mode to bonding

9. $1 passed; $2 not passed

10. Diff between "S" & "s" in "ls -l" output?

11. printf("%s", buf) where buf from aioread points 4 extra bytes?

12. "S" Loves Linux,, come on "S", you know it

13. the "s" and "S" permissions.