02-04-2011
Your spec can be described as "Keep printing lines from the one following the first matched to the last matched". You match the first line that you want, so you get a new line (getline), print it and then ask: Is this the line I want to match last? If yes then quit; otherwise, keep getting lines. So, as scottn points out, the first getline, the one that is out of the loop, should not be there because that is not what you want.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have an inputfile that I trying to awk with a getline(Solaris v8 ksh). However I need to have the results be a unique. Is there a comparable command within awk to return a unique result? Or can you break out of the awk to add a uniq. I am looking for something more complex then a pipe... (6 Replies)
Discussion started by: gozer13
6 Replies
2. UNIX for Dummies Questions & Answers
hi , I got a script that I don't understand.
awk '{
command="echo "$1
command | getline echome
close(command)
print $0 "\t" echome
}' < user.list
It reads the file user.list
user.list
London John
Bridge Peter
and sends the stream to the awk command.
I don't understand what is... (3 Replies)
Discussion started by: remid1985
3 Replies
3. Shell Programming and Scripting
hello collegues,
I am attempting to use awk to search file1 (serverlist.csv) from each row with file2 (supported.txt). If the is no entry exists in serverlist then output to a file called notsupp.out if there is an entry output to supp.out
I can do this with basic shell scripting however... (0 Replies)
Discussion started by: chlawren
0 Replies
4. Shell Programming and Scripting
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)
Discussion started by: Raynon
5 Replies
5. Shell Programming and Scripting
i'm new to shell scripting and have a problem please help me
in the script i have a nawk block which has a variable count
nawk{
.
.
.
count=count+1
print count
}
now i want to access the value of the count variable outside the awk block,like..
s=`expr count / m`
(m is... (5 Replies)
Discussion started by: saniya
5 Replies
6. Shell Programming and Scripting
hi people;
this is my two awk code:
nawk '/cell+-/{r=(NF==8) ? $4FS$5FS$6 : NF==7 ? $4FS$5 : $4 ;c=split(r,rr);for (i=1;i<=c;i++){if(rr != "111111"){printf($3" %d ""\n",(i+3))}}printf("")}' /home/gc_sw/str.txt > /home/gc_sw/predwn.txt
nawk -F'*' '{gsub(/ *$/,"")}$0=$1$($NF-2)'... (2 Replies)
Discussion started by: gc_sw
2 Replies
7. Programming
I can not get 'getline()' to compile. I have tried.
string curLine; //= compiler error
char* curLine; //=compiler error
char curLine; //=compiler error
Every example I see uses a string as a getline(); parameter. It does not work for me on Fedora14 with gcc-c++. Thank you so much. This... (1 Reply)
Discussion started by: sepoto
1 Replies
8. Shell Programming and Scripting
Here is I want to do:
find lines in file filteredtrace.txt which is not continued as
a multiply of 4 and strip them from file original_trace_framno.
problem is awk used the ' symbol
so pipe of getline has to use the " symbol
while agument of sed has to use the " symbol,
it doesn't... (8 Replies)
Discussion started by: lzq420241
8 Replies
9. Programming
Hi All,
When I do man getline on my Linux system (in BASH), I see an example C code where a file is being read using getline() function.
Now, my question is why there is no fclose() to close the open file pointer?
People who don't have a Linux system, this is the code that I am referring... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies
10. Shell Programming and Scripting
Hi.. i am running nawk scripts on solaris system to get records of file1 not in file2 and find duplicate records in a while with the following scripts -compare
nawk 'NR==FNR{a++;next;} !a {print"line"FNR $0}' file1 file2duplicate - nawk '{a++}END{for(i in a){if(a-1)print i,a}}' file1in the middle... (12 Replies)
Discussion started by: Abhiraj Singh
12 Replies