Computing.Net > Forums > Unix > awk and looping

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

awk and looping

Reply to Message Icon

Name: Coop
Date: October 18, 2005 at 10:12:47 Pacific
OS: Xp Pro
CPU/Ram: Pentium M/ 512 MB
Comment:

I have 3 files which I must awk seperately and I know I need a for loop but I'm not sure how to start it. Any ideas? Thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: Jim Boothe
Date: October 18, 2005 at 10:35:32 Pacific
Reply:

You do not need a loop to process the records in a file (or files).  However, you might want control-break logic to do something when your input file changes.  The following code shows a single awk print statement that is processing three files:

awk '{print NR, FNR, FILENAME}' file1 file2 file3
1 1 file1
2 2 file1
3 3 file1
4 4 file1
5 5 file1
6 6 file1
7 7 file1
8 8 file1
9 1 file2
10 2 file2
11 3 file2
12 4 file2
13 5 file2
14 6 file2
15 1 file3
16 2 file3
17 3 file3


0
Reply to Message Icon

Related Posts

See More


where to place the servic... Adding date to variable



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: awk and looping

awk and shell programming,need help www.computing.net/answers/unix/awk-and-shell-programmingneed-help/4944.html

Pause during gawk getline loop www.computing.net/answers/unix/pause-during-gawk-getline-loop/4556.html

awk and ksh www.computing.net/answers/unix/awk-and-ksh/7036.html