Grant,
There are mutliple instances of ":RECORD 1" (when I say :RECORD 1, specifically it is a "1" and not some other RecNo in the table.)
As such the exit statement will exit the program before all the records are returned if it finds a "RECORD 1" before the end...
Thanks Grant!
I made a slight modification (NF>=3) since there could be 3 or 4 fields in the record. There is a problem sometimes the file gets messed up and empty records are added to it, when this happens if the last record is as such, the array example you provided will not work. How can I...
Hi CaKiwi and marsd,
Sorry for not being clear. What I am trying to do is this:
If :RECORD 1 has X in field 2 lines below it (X being some number which is a shell variable) then print :RECORD 1, not the actual line with the X on it. If X appears in field 2 in a record it will appear on every...
Hi,
I want to return all the record numbers, between TABLENAME and END pairs, if it finds a match for X in field2 of that record.
The layout is as follows:
:TABLENAME
:RECORD 1
; Field2 Field3 Field 4
01, X, 99, 4321
02, X, 99, 4322
03, X, 99, 4323
04...
More info:
I am scanning certain tables in a comma-delimited file for some number (shell variable $1) in the 3 field of each record and then getting the index number of that record (field $1) when it finds a match. Then printing the output of the record under a table heading for each field...
I am running the following programs within one script. It works, however I would like a more professional way than to than to run 5 separate instances of awk. Any insight would be greatly appreciated.
Thanks.
nawk '/TABLE1/, /:TABLE2/' file | nawk -v X=$1 'BEGIN {FS=","} $3==X...
Hi,
I am scanning certain tables in a comma-delimited file for some number (shell variable $1) in the 3 field of each record and then getting the index number of that record (field $1) when it finds a match.
nawk '/table1/, /table2/' tempfile | nawk -v X=$1 'BEGIN {FS=","} $3 ~ X...
The variable declaration is working. The argument does not.
X=1234
cat tmpfile | awk -v awkX=${X} '$13 ~ awkX {print $0}'
+ cat tmpfile
+ awk -v awkX=1234 $13 ~ awkX {print $0}
awk: syntax error near line 1
awk: bailing out near line 1
X=some number
cat tmpfile | awk '$13~/"$X"/{print $0}'
what i want to do is to take a user defined variable and match it to field $13 in a text file. If the match is true then print the entire line. However, I don't seem to have the syntax correct for awk to understand $X is a...
Hi
I need assistance with a loop routine that counts the number of lines in a file then extracts the last line into a new file. The problem I am running into is the number of lines in file A will be dynamic.
I need a way to subtract the lines in File A one at a time and output them into File...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.