10 More Discussions You Might Find Interesting
1. 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
2. Shell Programming and Scripting
nawk '{ fmt="%3s %22s %48s %35s %21s\n"; if ($3==$6 && $1=="STOPLOSS") { tpy="Successful Match"; jnme=$1; sts="File will be loaded"; cntrl=$3; audit=$6; printf (fmt, tpy,jnme,sts,cntrl,audit) >> "'${AUDIT_DATA_FILE}/${AUDIT36}'" }else if ($3!=$6 && $1=="STOPLOSS") { tpy="Mis-Match ";... (4 Replies)
Discussion started by: wawa
4 Replies
3. Shell Programming and Scripting
I am trying to redirect record to two files using nawk if-else.
#Identify good and bad records and redirect records using if-then-else
nawk -F"|" '{if(NF!=14){printf("%s\n",$0) >> "$fn"_bad_data}else{printf("%s\n",$0) >> $fn}}' "$fn".orig
"$fn".orig is the source file name
bad... (7 Replies)
Discussion started by: siteregsam
7 Replies
4. Shell Programming and Scripting
hi guys,
I am writing a code and have stuck at one point. Inside nawk I am storing my desired variable a, I just need to find if a is present in an external file error.log or not. If yes, print something. grep or for loop not working properly inside nawk. Sample code provided.
nawk '
BEGIN... (5 Replies)
Discussion started by: shekhar2010us
5 Replies
5. Shell Programming and Scripting
HI,
My file contains data something like
034500,5,B5004946544EB185,DEFAULT,0
Now i want to do a pettern match for DEFAULT and remove that particular line from file and transfer the rest contents to temp file.But my req is i want to do case insensitive matching ie DEFAULT / default.
I... (4 Replies)
Discussion started by: centurion_13
4 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. Shell Programming and Scripting
I HAD these 2 files:
file1
pictures.txt 5 ref2313 4 ref2345 3 ref5432 2 ref4244 1
dance.txt 6 ref2342 5 ref2352 4 ref0695 3 ref5738 2 ref4948 1
treehouse.txt 6 ref8573 5 ref3284 4 ref5838 3 ref4738 2 ref4573 1
file2
pictures.txt 1 3
dance.txt 2 4
treehouse.txt 3 5
what I... (1 Reply)
Discussion started by: linuxkid
1 Replies
8. Shell Programming and Scripting
I have a file tmp.txt as shown below:
Controller: 0
Disk: 0.0.0
Disk: 0.1.0
Disk: 0.2.0
Controller: 1
Volume:c1t2d0
Disk: 0.0.0
Disk: 0.1.0
Disk: 0.2.0
Controller: 2
Volume:c2t2d0
Disk: 0.2.0
Now I want to split... (4 Replies)
Discussion started by: durbam2002
4 Replies
9. 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
10. UNIX for Advanced & Expert Users
I found a command who prints x lines before and after a line who contain a searched string in a text file.
The command is :
-------------------
nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r;print;c=a}b{r=$0}' b=2 a=4 s="string" file1
...where "b" and "a" are the number of lines to print... (2 Replies)
Discussion started by: ctap
2 Replies