Can any good awk'er resolve this issue?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Can any good awk'er resolve this issue?
# 8  
Old 12-03-2008
Try this:

Code:
awk -F^ '{ if (($1 != M) && ($5 != 2) && ($1 != S) && ($5 != 7)) print $0}' welcome > welcome1

Regards
# 9  
Old 12-03-2008
This command removes all the lines leaving C^E^2008^ZAT08^14.

My welcome1 file should have a content that does not have 'M' in the first col and '2' in the fifth col.

also it should not have 'S' in the first col. and '7' in the fifth col.

rest of the o/p must be displayed.
# 10  
Old 12-03-2008
It should work, this is my output:

Code:
$ cat file
S^E^2008^12G43^7^
C^E^2008^ZAT08^14
S^E^2008^ZAR48^22
M^E^2008^0TL69^2^
S^E^2008^FCB67^30
$
$
$ awk -F^ '{ if (($1 != M) && ($5 != 2) && ($1 != S) && ($5 != 7)) print $0}' file
C^E^2008^ZAT08^14
S^E^2008^ZAR48^22
S^E^2008^FCB67^30
$
$

# 11  
Old 12-03-2008
Great franklin .... thanks for your help
# 12  
Old 12-03-2008
Use:

awk -F^ '{ if ((($1 != "M") && ($5 != "7")) || (($1 != "S") && ($5 != "2"))) print $0}' welcome > welcome1
# 13  
Old 12-03-2008
Or:

Code:
awk -F^ '!($1~/^(M|S)$/&&$5~/^(2|7)$/)' infile

 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Looking for good book on awk

I am not sure if I am posting to the right forum but I would like to buy a book which goes into Awk in detail and covers the most advanced Awk programming techniques. Would anybody be able to recommend a good book? I see plenty of books available on Amazon but I am not sure how detailed they are.... (2 Replies)
Discussion started by: kieranfoley
2 Replies

2. Solaris

Cannot resolve PTR record issue

Hi guys, I am currently receiving the following output in /var/log/syslog and is occurring every second leading to /var directory being full after every 2 days. Aug 20 17:32:29 opaldn1 sendmail: r7KCOlQm002517: ruleset=check_rcpt, arg1=<postmaster@silverapp6>, relay=, reject=450 4.4.0... (3 Replies)
Discussion started by: Junaid Subhani
3 Replies

3. Shell Programming and Scripting

Cannot resolve $variable in awk

My script ---------- for i in `cat n`;do export k=`echo "CSN: "$i` //combining CSN: and value from n echo "$k" awk ''{print "CSN: "$0;}'{_=29}_&&_--' file1|tail -1 >> file2 done In the above script i cannot able to resolve $k in awk command file n contains ------------ 0000 1111 2222... (2 Replies)
Discussion started by: Mohana29_1988
2 Replies

4. Shell Programming and Scripting

Cannot resolve $var in awk

My script ---------- for i in `cat n`;do export k=`echo "CSN: "$i` //combining CSN: and value from n echo "$k" awk ''{print "CSN: "$0;}'{_=29}_&&_--' file1|tail -1 >> file2 done In the above script i cannot able to resolve $k in awk command file n contains ------------ 0000 1111... (0 Replies)
Discussion started by: Mohana29_1988
0 Replies

5. Shell Programming and Scripting

Need awk good link

Guys, I am always struggling with awk and sed commands in UNIX,especially while writing shell script. Can you please suggest some good websites? Cheers, Aravind (3 Replies)
Discussion started by: AraR87
3 Replies

6. Shell Programming and Scripting

The awk subtraction giving exponential values.Please help resolve it

Hi friends, I have a file list1 which has these 2 columns like 616449 0 434453 1 2151083 0 2226536 0 2132382 0 2136814 0 I have to put the result of col1 -col2 into another file list2 linewise. e.g. It gives the below result if use the below code: awk '{ print $1 - $2 }' list1 >... (2 Replies)
Discussion started by: kunwar
2 Replies

7. Shell Programming and Scripting

Need assistance to resolve the KSH issue

am running the small script below. count_a=48 count_b=48 if ; then echo "Count matched" else echo "count not matched" fi I got the below output. /bin/ksh: [48: not found count not matched It was giving the same error when I ran in another box. But I inculded /bin/ksh in the... (10 Replies)
Discussion started by: sathik
10 Replies

8. Shell Programming and Scripting

Does awk ever resolve params ?..

Hi, Does awk ever resolve params in the search pattern?.. The following awk doesnt know how to resolve ${tables}$ inside a loop. k=`awk '/${tables}$/ ${graph}` The search pattern has ${tables}$ and I am narrowing down my search with a $ at the end of string. So...this leaves me with a... (13 Replies)
Discussion started by: anduzzi
13 Replies
Login or Register to Ask a Question