How To display second coloumn values


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How To display second coloumn values
# 1  
Old 07-22-2008
Hammer & Screwdriver How To display second column values

i have a file like this .....


empno ----- ename ----- job

1 ----- scott----- manager

2----- ford----- salesman

3 ----- mark---- president

in this i wanna display second column means ename column values as ouput
like this

scott
ford
mark

which command is used in this case ?

sorry if repost ......but plzzzzzzzz help me ......

Last edited by naughty21; 07-22-2008 at 02:43 AM..
# 2  
Old 07-22-2008
Code:
perl -ne '@arr=split("-----",$_);print $arr[1],"\n";'

# 3  
Old 07-22-2008
Quote:
Originally Posted by summer_cherry
Code:
perl -ne '@arr=split("-----",$_);print $arr[1],"\n";'

i want for unix....is this for unix ?

Last edited by naughty21; 07-22-2008 at 03:19 AM..
# 4  
Old 07-22-2008
Not a real script Smilie but can do your job.
Code:
awk '/^[0-9]/{gsub("-","",$0);print $2}' file


Last edited by danmero; 07-22-2008 at 03:25 AM..
# 5  
Old 07-22-2008
Code:
cat {filename} | awk -F "-----" '{print $2}'

# 6  
Old 07-22-2008
Quote:
Originally Posted by ynilesh
Code:
cat {filename} | awk -F "-----" '{print $2}'

Did you check the output?
Code:
$ cat file | awk -F "-----" '{print $2}'

 ename

 scott

 ford

 mark---- president

And the UUOC Smilie
# 7  
Old 07-22-2008
thanks for ur replies ..........

Last edited by naughty21; 07-22-2008 at 11:44 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Merge the three csv files as one according to first coloumn.

I have three files with similar pattern i need to merge all the coloumns side by side from all three files according to the first coloumn example as shown below I mentioned 5 coloumns only in example but i have around 15 coloumns in each file. file1: Name,Samples,Error,95RT,90RT... (4 Replies)
Discussion started by: Raghuram717
4 Replies

2. UNIX for Beginners Questions & Answers

Replace in the specific coloumn of a csv

I have a CSV with 6 coloumn. I need to replace a ',' with '|' in the 4th coloumn of a CSV only so i can upload in Database. When i Upload now, commas used in the text in the 4th coloumn are treated as delimiter and remaining text goes to the next coloumn. Any solutions to replace, thanks. (1 Reply)
Discussion started by: adnan11
1 Replies

3. UNIX for Dummies Questions & Answers

Using ls command to display files for range of values only

Hi Forum. I tried to search the forum for an answer but couldn't find it. I have the following files in my directory: PROFILE_TXN_61647.dat PROFILE_TXN_61648.dat PROFILE_TXN_61649.dat PROFILE_TXN_61650.dat PROFILE_TXN_61651.dat PROFILE_TXN_61652.dat PROFILE_TXN_61653.dat... (8 Replies)
Discussion started by: pchang
8 Replies

4. UNIX for Dummies Questions & Answers

Combining two files with a reference coloumn

Hi all, this is file1.txt 10.210.226.21 alarmSupervisionActive=true 10.64.136.209 alarmSupervisionActive=true 10.64.174.209 alarmSupervisionActive=true 10.64.182.65 alarmSupervisionActive=true 10.66.193.113 alarmSupervisionActive=true 10.80.124.67 alarmSupervisionActive=true ... (6 Replies)
Discussion started by: sau_boy
6 Replies

5. UNIX for Dummies Questions & Answers

transponse row to coloumn output

dears i have row data as below: ======================================================================================== Session Count: 24580 Session Count: 13426 Session Count: 22533 Session Count: 0 Session Count: 0 Session Count: 15036 Session Count: 11625 Session Count: 6942... (3 Replies)
Discussion started by: thehero
3 Replies

6. Shell Programming and Scripting

How to display fields and values in sql+ for Oracle DB

Hello, I'm trying to do a select for an Oracle table but the output gives me only filelds values without fields name as in Informix. Is there anyway to display both in output ? For instance, the output will be : Name Rico Age 30 Position Engineer Thx, (5 Replies)
Discussion started by: rany1
5 Replies

7. Shell Programming and Scripting

have to retrieve the distinct values (not duplicate) from 2nd column and display

I have a text file names test2 with 3 columns as below . We have to retrieve the distinct values (not duplicate) from 2nd column and display. I have used the below command but giving some error. NS3303 NS CRAFT LTD NS3303 NS CHIRON VACCINES LTD NS3303 NS ALLIED MEDICARE LTD NS3303 NS... (16 Replies)
Discussion started by: shirdi
16 Replies

8. UNIX for Dummies Questions & Answers

How to display values from user input array?

Hi all, I wrote a script that reads inputs from user and store in array named "input". The number of elements in the array is not fixed - determined only after user exit the while loop that reads the array values : x=1 echo "Enter first value" read input while } != "exit" ] do ... (1 Reply)
Discussion started by: luna_soleil
1 Replies

9. UNIX for Dummies Questions & Answers

How to copy one coloumn from one file to another

Hi All, I have two files in which i want to copy one coloumn from one file to another such that it appears as a separate coloumn in the other file.Please note there already exists a coloumn in the other file.For eg in file 1(first file) i have 12 23 35 in file 2(other file) i have 34 45... (2 Replies)
Discussion started by: navjotsingh
2 Replies

10. UNIX for Dummies Questions & Answers

How to Display a range of values in the output of cat

When I use this command I get an output of some numbers cat ac.20070511 | cut -d" " -f19 Is there any way for me to display only the numbers that are greater than 1000 but not all the numbers in the ouput. Can any one help me with this. :) (8 Replies)
Discussion started by: venu_nbk
8 Replies
Login or Register to Ask a Question