Help: for display the 1 column from one file? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Help: for display the 1 column from one file?

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-11-2006
surainbow surainbow is offline
Registered User
 
Join Date: Dec 2006
Last Activity: 4 January 2012, 10:09 PM EST
Posts: 26
Thanks: 1
Thanked 0 Times in 0 Posts
Power Help: for display the 1 column from one file?

Hi, boss
i have a problem:
i want display one column from a file.
so i think i can used the awk -F"," '{print $number}' XXXX.
but the file contain lots of the column,,,so i can confirm the line number which i need .
so can some body help me to solve this issus.......

PS: how can i display the any row or any column by the UNIX command?
Sponsored Links
    #2  
Old 12-11-2006
reborg's Avatar
reborg reborg is offline Forum Advisor  
Administrator Emeritus
 
Join Date: Mar 2005
Last Activity: 29 March 2012, 7:00 PM EDT
Location: Ireland
Posts: 4,464
Thanks: 0
Thanked 11 Times in 11 Posts
The row will work with the awk statement you posted.

for rows:

Code:
awk 'NR==number"  # where number is the row you want.

or

Code:
sed -n '2p'   # where 2 is 2nd row

Sponsored Links
    #3  
Old 12-11-2006
surainbow surainbow is offline
Registered User
 
Join Date: Dec 2006
Last Activity: 4 January 2012, 10:09 PM EST
Posts: 26
Thanks: 1
Thanked 0 Times in 0 Posts
I know that, but how to check the number of the column? due the table is very big, and do i need count that manually? or can i filter that column by key words?
like: name class .............. age
kevin 5 26
so i do not know the exactly column of the age, but i know there is a column include the "age" key words.
can i filter that column by keywords?
thanks very much!
    #4  
Old 07-21-2008
naughty21 naughty21 is offline
Registered User
 
Join Date: Jun 2008
Last Activity: 11 February 2009, 8:53 PM EST
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
how to display the 2nd coloumn from a file ........
for ex....

empno ename
1 scott
2 ford

need to display 2nd coloumn
how ? any help ?
Sponsored Links
    #5  
Old 07-22-2008
DukeNuke2's Avatar
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
 
Join Date: Jul 2006
Last Activity: 19 December 2014, 2:19 PM EST
Location: Berlin, Germany
Posts: 5,431
Thanks: 55
Thanked 231 Times in 224 Posts
i've moved this thread to "shell programming..."

@naughty21
please don't capture old threads for new questions. just start a new thread in the right forum...

for your question try this:

Code:
cat /your/file | cut -d " " -f2

Sponsored Links
    #6  
Old 07-22-2008
ghostdog74 ghostdog74 is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 9 November 2014, 12:24 AM EST
Posts: 2,669
Thanks: 0
Thanked 18 Times in 18 Posts
to display second column

Code:
awk '{print $2}' file

to know how many columns

Code:
awk '{print NF}' file

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2 rydz00 Shell Programming and Scripting 7 11-09-2010 11:28 AM
Search name and display column from a file sillyha Shell Programming and Scripting 3 01-31-2010 10:58 PM
How to display the first column in a file? isha_1 Shell Programming and Scripting 5 12-14-2009 01:25 AM
Changing one column of delimited file column to fixed width column manneni prakash Shell Programming and Scripting 5 06-22-2009 06:27 AM
display column in a row vivekshankar UNIX for Dummies Questions & Answers 2 05-23-2005 05:43 PM



All times are GMT -4. The time now is 04:12 PM.