Awk Utilities


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Awk Utilities
# 1  
Old 05-08-2008
Question Awk Utilities

Hi,
My input file is like this
1 11110001 1.1.1.1.1
2 12222212 2.3.44.5.6
3 22223333 1.3.2.4.1.55

Now i need the 2nd column value get printed
I tried with the following command
awk 'NR==1 {print $2}' input

this works fine for only 1st row.I need to change always NR assigned value to get printed all the 2nd column values so i tried like this but i m not getting

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

But i am not getting any value printed
# 2  
Old 05-08-2008
It works fine for me to do
awk '{print $2}' filename
# 3  
Old 05-08-2008
Thanks for ur help but I actually need 1st row's 2nd column value.Like in the input file i need only 11110001 to be printed ,then after 1 iteration it should print 2nd row 2nd column value then 3rd row 2nd column value
# 4  
Old 05-08-2008
I'm not shure if I understand your question, but the command I gave you will give you this output:

11110001
12222212
22223333

Is'nt this what you are trying? Else show the output you want.
# 5  
Old 05-08-2008
see
Index=`awk 'NR==1 print $2}' input`
value=Index+3000

so the output will be 11113001
Like this it has to use for all the rows one by one

similar to this
for(i=1;i<=3;i++)
do
Index=`awk 'NR==$i print $2}' input`
value=Index+3000
echo $value
done
# 6  
Old 05-08-2008
If the value 3000 remains same for all the iterations then
Code:
awk '{ print $2+3000 }' file

# 7  
Old 05-08-2008
Actually i need the value of 1st row and 2nd column once i.e 11110001 and do a set of operations on that value .I gave just example of adding 3000 but i have set of operations using that value.Then after all operations done it has iterate by itself and give the 2nd row 2nd column value to perform the set of operations .Then the 3rd row 3rd column...please give me the suggestion on how to capture one by one

Last edited by jyo123.jyothi; 05-08-2008 at 06:13 AM.. Reason: Grammar
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