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

  Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Help: for display the 1 column from one file?

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 12-11-2006
reborg's Unix or Linux Image
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 Unix and Linux 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 Unix and Linux 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 Unix and Linux 07-22-2008
DukeNuke2's Unix or Linux Image
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
 
Join Date: Jul 2006
Last Activity: 1 April 2015, 8:29 AM EDT
Location: Berlin, Germany
Posts: 5,465
Thanks: 59
Thanked 238 Times in 231 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 Unix and Linux 07-22-2008
ghostdog74 ghostdog74 is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 28 January 2015, 8:30 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 10:28 AM
Search name and display column from a file sillyha Shell Programming and Scripting 3 01-31-2010 09:58 PM
How to display the first column in a file? isha_1 Shell Programming and Scripting 5 12-14-2009 12:25 AM
Changing one column of delimited file column to fixed width column manneni prakash Shell Programming and Scripting 5 06-22-2009 05:27 AM
display column in a row vivekshankar UNIX for Dummies Questions & Answers 2 05-23-2005 04:43 PM



All times are GMT -4. The time now is 06:30 PM.