Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

wwwxxxAPC, How to unsubscrube from dategen spam, WWWXXXAPC, docmd.close 2585, WWWXXXDOCO, nu vot, dhcpd lease file "binding state", WWWXXXDOCO, how to setup procmail to process html2text, how to setup procmail html2text

Links

XODOX
Impressum

#1: awk

Posted on 2008-04-21 03:04:27 by alexus

how can I have awk to print me whole line excluding $1

echo 1 2 3 4 5 | awk .....

2 3 4 5

Report this message

#2: Re: awk

Posted on 2008-04-21 03:44:34 by Bill Marcum

On 2008-04-21, alexus <alexus@gmail.com> wrote:
>
>
> how can I have awk to print me whole line excluding $1
>
> echo 1 2 3 4 5 | awk .....
>
> 2 3 4 5
A simple obvious way is awk '{$1="";print}'

Report this message

#3: Re: awk

Posted on 2008-04-21 04:22:22 by Ed Morton

On 4/20/2008 8:04 PM, alexus wrote:
> how can I have awk to print me whole line excluding $1
>
> echo 1 2 3 4 5 | awk .....
>
> 2 3 4 5

I'd use "cut" instead:

$ echo 1 2 3 4 5 | awk '{sub(/[^ ]* */,"")}1'
2 3 4 5
$ echo 1 2 3 4 5 | sed 's/[^ ]* *//'
2 3 4 5
$ echo 1 2 3 4 5 | cut -d' ' -f2-
2 3 4 5

Ed.

Report this message

#4: Re: awk

Posted on 2008-04-21 13:17:20 by Stephane CHAZELAS

2008-04-20, 21:22(-05), Ed Morton:
> On 4/20/2008 8:04 PM, alexus wrote:
>> how can I have awk to print me whole line excluding $1
>>
>> echo 1 2 3 4 5 | awk .....
>>
>> 2 3 4 5
>
> I'd use "cut" instead:
>
> $ echo 1 2 3 4 5 | awk '{sub(/[^ ]* */,"")}1'
> 2 3 4 5

But:

$ echo " 1 2 3 4 5" | awk '{sub(/[^ ]* */,"")}1'
1 2 3 4 5

You may want:

echo " 1 2 3 4 5" | awk '{sub(/[^ ]+ */,"")}1'
or
echo " 1 2 3 4 5" | awk '{sub(/ *[^ ]+ */,"")}1'

> $ echo 1 2 3 4 5 | sed 's/[^ ]* *//'

sed's equivalent of awk's + is \{1,\}.

echo " 1 2 3 4 5" | sed 's/[^ ]\{1,\} *//'

> 2 3 4 5
> $ echo 1 2 3 4 5 | cut -d' ' -f2-
> 2 3 4 5
[...]

The problem with cut is that it has a different definition of
"field" from awk's one.

--
Stéphane

Report this message

#5: Re: awk

Posted on 2008-04-21 18:32:46 by alexus

On Apr 20, 9:04=A0pm, alexus <ale...@gmail.com> wrote:
> how can I have awk to print me whole line excluding $1
>
> echo 1 2 3 4 5 | awk .....
>
> 2 3 4 5

thank you guys!

Report this message

#6: Re: awk

Posted on 2008-04-23 00:14:54 by Chris Mattern

On 2008-04-21, alexus <alexus@gmail.com> wrote:
> how can I have awk to print me whole line excluding $1
>
> echo 1 2 3 4 5 | awk .....
>
> 2 3 4 5

awk is the wrong tool. cut is the correct tool, being
fully capable of the task and much more lightweight
than awk.

$ echo 1 2 3 4 5 | cut -d" " -f 2-
2 3 4 5
$

--
Christopher Mattern

NOTICE
Thank you for noticing this new notice
Your noticing it has been noted
And will be reported to the authorities

Report this message