Awk Utilities


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Awk Utilities
# 8  
Old 05-08-2008
How abt this

Code:
awk -F" "  'NR==1 { print $2+1000} NR==2 { print $2+2000} NR==3 { print $2+3000}' file

In the actions...u may cary out your set of operations....
I have just considered a sample eg..
# 9  
Old 05-08-2008
Thanks ..
but i have lot of operations ...i cant put all of them in one command line ...thats why i am trying to put in for loop....Do u have any suggestions to use awk in loop
# 10  
Old 05-08-2008
Awk itself iterates over the file....so no need to loop through each of the lines...

About the set of operations...There is no restriction on no.of commands...

refer below...some more set of operations...on NR==1

Code:
awk -F" "  'NR==1{val=$2;print val + 1000, val*2}' file

Hope this explains and help...Smilie
# 11  
Old 05-08-2008
Hey i got the solution

for(i=1;i<=3;i++)
do
Index=`awk 'NR=='$i' {print $2}' input`
value=Index+3000
echo $value

Thanks to all of u

Last edited by jyo123.jyothi; 05-08-2008 at 06:46 AM.. Reason: syntax
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Crontab utilities

Hi gurus/lead, I have one doubt in crontab. I have shell script source code in one server. where I don't have priviliges acess R/W the shell script in that server. how can I setup the crontab to pick the code from the other unix server ? whether is there any possibility. in my... (1 Reply)
Discussion started by: ramkumar15
1 Replies

2. UNIX and Linux Applications

Utilities for CSV

I'd like to be able to do something like 'select column_a column_c column_b from file.csv'. Scripting it probably wouldn't be too extraordinarily difficult but I'd rather not reinvent the wheel if someone's built a better one already. (3 Replies)
Discussion started by: Corona688
3 Replies

3. UNIX for Advanced & Expert Users

utilities

hi experts, i have a file sample: ======= 000123 5 7 0008 00345 5 9 0004 how can i get an output as 123 5 7 8 345 5 9 4 thanks in an advance subhendu (5 Replies)
Discussion started by: subhendu81
5 Replies

4. UNIX for Advanced & Expert Users

non GNU utilities

Hi Chaps, Does anyone know of a source of proprietary unix utilities. I often fall into the trap of testing a spot of code on my linux machine, posting the answer in the forums and then realise that the solution may only work with the GNU utils that I use, and not standard posix ones (if there are... (4 Replies)
Discussion started by: wempy
4 Replies

5. UNIX for Dummies Questions & Answers

how to run utilities

I have utilities installed on a UNIX platform and was wondering how i run them. (1 Reply)
Discussion started by: hershey101
1 Replies

6. UNIX for Dummies Questions & Answers

bc and wc utilities???

Hi, Can anybody explain bc and wc system utilities in Unix? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

7. HP-UX

version of the utilities

Hi, Can anyone tell me how i can know the version of the utilities (to be specific "make" and "ar") in HP-UX ver 11.00. thanks, abey. (3 Replies)
Discussion started by: abey
3 Replies

8. UNIX for Dummies Questions & Answers

compression utilities

I've noticed bzip2 gives a little bit better compression than gzip. So...I'm curious...what's gives the best compression out of all the compression utilities? Thanks! (6 Replies)
Discussion started by: jalburger
6 Replies

9. UNIX for Dummies Questions & Answers

Zmodem Utilities

Where can I find Zmodem utilities for Soloris 7 ie: rz sz thnx (1 Reply)
Discussion started by: SmartJuniorUnix
1 Replies
Login or Register to Ask a Question