Code Comments
Programming Forum and web based access to our favorite programming groups.Hallo, I have a listing with following form: a b c d xx y zz.txt f r f g yz x xx zzz.doc
Post Follow-up to this messageIn article <7966a6cc.0402260540.79f08419@posting.google.com>,
Brigitte Selch <Brigitte_Selch@mn.man.de> wrote:
>Hallo,
>
> I have a listing with following form:
>
> a b c d xx y zz.txt
> f r f g yz x xx zzz.doc
>
> .
> .
> .
>
> Now ich want to eliminate the first 4 columns and print the all
> following columns as they are (with multiple blanks, because they ar
e
> filenames).
> In my example:
>
> xx y zz.txt
> yz x xx zzz.doc
I'm not sure I understand the underlying problem - what exactly is this
data, and, if they are filenames, why do you need to preserve the
inter-field spacing - but anyway, this is a well-known "feature" of AWK (*),
and here is one solution (**).
{
for (i=0; i<4; i++)
sub("[ \t]*"$1"[ \t]*","")
print
}
(*) It has its plusses and minusses.
(**) Modulu issues of reg ex magic chars in $1.
Post Follow-up to this messageHi Brigitte,
index($0,$5) returns the index of $5 in the string $0.
substr($0,index($0,$5)) returns the rest of $0, starting at the
beginning of $5.
awk '{print substr($0,index($0,$5));}'
HTH,
Stefan
Brigitte Selch schrieb:
> I have a listing with following form:
>
> a b c d xx y zz.txt
> f r f g yz x xx zzz.doc
[...]
> Now ich want to eliminate the first 4 columns and print the all
> following columns as they are (with multiple blanks, because they a
re
> filenames).
> In my example:
>
> xx y zz.txt
> yz x xx zzz.doc
Test:
awk '{print substr($0,index($0,$5));}' << EOF
> a b c d xx y zz.txt
> f r f g yz x xx zzz.doc
> EOF
xx y zz.txt
yz x xx zzz.doc
Post Follow-up to this messageHello, Wow, it works. Thank you very much, Brigitte
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.