awk
am 21.04.2008 03:04:27 von alexushow can I have awk to print me whole line excluding $1
echo 1 2 3 4 5 | awk .....
2 3 4 5
how can I have awk to print me whole line excluding $1
echo 1 2 3 4 5 | awk .....
2 3 4 5
On 2008-04-21, alexus
>
>
> 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}'
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.
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
On Apr 20, 9:04=A0pm, alexus
> 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!
On 2008-04-21, alexus
> 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