Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

conditional replacement
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

Report this thread to moderator Post Follow-up to this message
Old Post
christian
11-23-04 08:55 PM


Re: conditional replacement
w_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!

Report this thread to moderator Post Follow-up to this message
Old Post
christian
11-24-04 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

AWK archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:24 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.