Code Comments
Programming Forum and web based access to our favorite programming groups.hi,
i would like replace line 2 if in line 4 for thousand of files?
Unlucky my below attempt works not until now, because i find no example in t
he web
how i refer to line 2 and 4 optimal and i'm not sure whta's the perfect tool
-
bash only, sed or awk?
for i in * do ; awk `/type,1/ {sub(/lfdn,/,"lfdn,100")}` $i ; done
many
thanks
Christian
Post Follow-up to this messagew_a_x_man@yahoo.com (William James) wrote in message news:<f8860640.0411212323.15e4edbe@pos
ting.google.com>...
> ozric@web.de (christian) wrote
>
>
> -----
>
> # If "type,1" is found in line 4, then in line 2 "lfdn," needs to be
> # changed to "lfdn,100".
> NR > 1 && NR<5 {
> if ( 4==NR )
> { if ( $0 ~ /type,1/ )
> sub( /lfdn,/, "lfdn,100", a[2] )
> print a[2] "\n" a[3]
> print
> }
> else
> a[NR] = $0
> next
> }
>
> { print }
>
> -----
>
> Is this what you want?
Yes that's a perfect starting point - many thanks!
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.