LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-17-2008, 03:28 AM   #1
lawrence_lee_lee
Member
 
Registered: May 2007
Posts: 141

Rep: Reputation: 16
How to use "awk" to do the following seemingly simple work?


1) Given an input file, I want to perform some action to a line subject to some conditions of the next line. For example,

if the next line is "======" then I want to print the current line.
How can such actions be performed using awk?

2) Is there any method for awk to go back one/more line(s) when reading a file?

3) What is the difference between these two intrinsic variables: NR and FNR?

4) Does awk support multidimensional array?
 
Old 04-17-2008, 04:29 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by lawrence_lee_lee View Post
2) Is there any method for awk to go back one/more line(s) when reading a file?
No.

Quote:
Originally Posted by lawrence_lee_lee View Post
1) Given an input file, I want to perform some action to a line subject to some conditions of the next line. For example,

if the next line is "======" then I want to print the current line.
How can such actions be performed using awk?
Store each line in a transient buffer, compare to current and
print it.

Quote:
Originally Posted by lawrence_lee_lee View Post
3) What is the difference between these two intrinsic variables: NR and FNR?
NR is the TOTAL number of records seen, FNR pertains
to the "current file".

Quote:
Originally Posted by lawrence_lee_lee View Post
4) Does awk support multidimensional array?
Yes.



Cheers,
Tink
 
  


Reply

Tags
awk



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
awk question on handling *.CSV "text fields" in awk jschiwal Programming 8 05-27-2010 06:23 AM
Replacing "function(x)" with "x" using sed/awk/smth Griffon26 Linux - General 3 11-22-2006 10:47 AM
Any way to get "Alice"; "Call of Duty" series and "Descent 3" to work? JBailey742 Linux - Games 13 06-23-2006 01:34 PM
"<" ">" Keyboard keys on Toshiba Satellite 1005-s157 dont work RodCas Linux - Laptop and Netbook 1 05-08-2004 04:22 PM
<input type="button" disabled="true" > does not work in ns4.7 or 4.9 cybercop12us Programming 2 11-29-2002 08:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration