I was expecting to see the "before" in my printf() literaly before "pattern" each time i cycle through the while loop, but i'm only getting it the first time it loops through..
no, because you're overwriting the the whole record/line on every iteration through the 'while' loop - chopping it up to 'nothing' with 'match' and the '$0=...' assignment.
An alternative - holding on to the FIRST 'before' pattern and printing it out for every 'match':
Hi
I am using Solaris 5.10 & ksh
Wanted to loop through a pattern file by reading it and passing it to the awk to match that value present in column 1 of rawdata.txt , if so print column 1 & 2 in to Avlblpatterns.txt. Using the following code but it seems some mistakes and it is running for... (2 Replies)
Using a bash for loop to pass variables into a nawk loop to capture a string in an sftp log. Tried several different syntax methods to have the variable treated as a regex so the loop will capture the string.
for i in `cat /tmp/dar3.out.2`
do
nawk -vst=$i '$5 ~ /$st/ && /closed/ && /user/... (3 Replies)
I have a file with the contents below "lets say the name of the file is abcxyz" shown at the end of this.
I am using nawk to find the exact ip address and the 6 lines after the match is found using the following nawk statement
/usr/bin/nawk "/111.46.14.107/,printed==6 { ++printed; print; }"... (7 Replies)
Hi,
I just need to check whether number of digits in a phone number is 10 or not. If I am not wrong regex will be: {9}
I have to use this inside nawk as this is a small portion of a big program.
nawk '
BEGIN { RS="";FS=";";
regex="{9}";
}
{
for (i=1;i<=NF;i++) {
if... (6 Replies)
I am new to scripting and this is probably the 4th or 5th simple script I have written. I am working with a HUGE number of data that need to be organized into folders and named a certain way. I wrote the naming script using a while function to go through the 1000-some folders and rename the files... (0 Replies)
I am scanning a file (line by line) for format errors. A line could have multiple errors. Each field in the line is evaluated for errors and sent, along w/ any error messages, to a temporary file. Finally, if any errors were detected, this temporary file is then appended to the errorFile. The... (4 Replies)
i am matching two files.
the files are in the format
file_1.txt
1|_|X|_|
2|_|W|_|
3|_|Y|_|
4|_|Z|_|
5|_|U|_|
file_2.txt
W|_|A|_|
Z|_|C|_|
V|_|B|_|
X|_|D|_|sdff|_|
Y|_|
file_3.txt should be in the format (4 Replies)
Hi,
I am using a Solaris OS here. My intention is to print the 2nd field if the first field matches "APPLE=". I am using the "getline" function here (shown below), but it doesn;t work. Can any experts give me some advice?
Input:
ORANGE= 10
APPLE= 20
MANGO= 30
GRAPES= 40
Output:
20
... (5 Replies)
Hi All,
I am using solaris and nawk.
Is there any time function in nawk which is simliar to the shell `date` function ?
Can any experts show any examples? (4 Replies)
HELP!!!! I am in an on-line shell programming class and have a question. Here is the data:
Mike Harrington:(510) 548-1278:250:100:175
Christian Dobbins:(408) 538-2358:155:90:201
Susan Dalsass:(206) 654-6279:250:60:50
(There are 12 contribuors total)
This database contains names, phone... (1 Reply)