Please help


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Please help
# 1  
Old 01-04-2006
Please help

test 100 abc
test 134 bcd
test 356 cdf
test 831 dfg
test 720 fgh

Dear friends,

This is the file i have. I try to do the following:

a. to replace the third column on the first line with ABC, second line BCD and so on for all of the third column. (please advise with replacement comand)

b. to grep only the 100 and the 831

my final result should be:

100 ABC
831 DFG

Thank you much!
# 2  
Old 01-04-2006
Code:
nawk '$2 == 100 || $2 == 831 {print $2, toupper($3) }' myFile

# 3  
Old 01-04-2006
Replace

test 100 abc
test 134 bcd
test 356 cdf
test 831 dfg
test 720 fgh

Please advise how can I replace the abc, bcd....with ABC, BCD....

Thanks!
# 4  
Old 01-05-2006
Quote:
Originally Posted by bobo
test 100 abc
test 134 bcd
test 356 cdf
test 831 dfg
test 720 fgh

Please advise how can I replace the abc, bcd....with ABC, BCD....
I'm sure if you understand the previous post, you'll find an answer to this one!
Quote:
Originally Posted by bobo
Thanks!
[/quote]
# 5  
Old 02-08-2006
Power please help

This is great code!
nawk '$2 == 100 || $2 == 831 {print $2, toupper($3) }' myFile

I want to get all the data if it is NOT EQUAL to 100. I tried:

nawk '$2 <> 100 {print $2, toupper($3) }' myFile

It is not work! what can I use instead of <>

Many thanks!
# 6  
Old 02-08-2006
not equal is !=
# 7  
Old 02-08-2006
using grep and awk

grep -v 100 myfile|awk '{print $1, $2, toupper($3)}'

Cheers,
Gaurav


PS: This is not tested please check it
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question