AWK problem need help
- From: Akhil <akhileshpatil@xxxxxxxxx>
- Date: Tue, 19 Jun 2007 10:15:51 -0000
Hi,
I am trying out an "AWK" script, to search and modify some pattern in
text file.
The script is as follows:
NR<100 {
if ( ( $6 ~ /^(x|X)/ ) || ( $4 ~ /^(x|X)/ ) ) {
printf ("PAT:%s\n", $prev)
print NR, $0
z = split($prev, lastline, " ")
if ( lastline[0] ~ /^\/\// ) {
print NR >> "bin/output.atp"
}
if ( lastline[0] ~ /repeat/ ) {
print NR, NR >> "bin/output.atp"
} else {
print NR, NR, NR >> "bin/output.atp"
}
} else {
print $0 >> "bin/output.atp"
prev = $0
}
}
My observation here is:
In else part (i.e. when I dont get the regx match, I am trying to
store the line read) in a variable, and I wnated to use it later. But
when I try printing the variable "prev" next time when I have "regx"
match, it displays the current line i.e. $0 itself
Please suggest some alternative to store the previously read line.
Akhil
.
- Follow-Ups:
- Re: AWK problem need help
- From: Ed Morton
- Re: AWK problem need help
- Prev by Date: Connect shell and mysql
- Next by Date: Re: compair files
- Previous by thread: Connect shell and mysql
- Next by thread: Re: AWK problem need help
- Index(es):
Relevant Pages
|