Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk input command??

Status
Not open for further replies.

lambros

Programmer
Oct 10, 2002
42
US
Hi,

Is there some command in awk to go back to the start of the input record?
 
what's "input record"?

The paradigm is that you process a file one record at the time. The records are separated by by the value of RS variable [NewLine by default].

The "current" record is accessed by by either $0 in its entirety.

There's no "explicit" operator to go back to the FIRST record read - once the record has been processed it's gone.

You can "save" a particular record [FIRST for example] explicitely in your code and make your processing decissions based on the content of the "saved" record.

Is that something that you're after?
vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Sort of I think Vlad,

You see the problem with my assignment, is that once my script uses processes the record, I need to assign a variable to the relevant record, then go back and test this variable against the entire input record again. Is this possible?
 
sure. Something like that [mnemonic code]

{
assignedVariable=yourProcessingGoesHere
if ( assignedVariable != processSameRecordAgain)
next;
}

{
# here comes your logic to REprocess the same record
} vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Hi Vlad,

What exactly do you mean by the line;

if ( assignedVariable != processSameRecordAgain)
 
The 'assignedVariable&quot; variable will contain the 'result' of your processing in step ONE.

The 'processSameRecordAgain' will contain some kind of the 'indicator' to determine if your processing of the same record the SECOND time.

Remember, this is all mnemonic. vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top