![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Changing one column of delimited file column to fixed width column | manneni prakash | Shell Programming and Scripting | 5 | 06-22-2009 05:27 AM |
| Replacing column with column of another file | manneni prakash | UNIX for Dummies Questions & Answers | 1 | 06-24-2008 11:20 PM |
| How to check Null values in a file column by column if columns are Not NULLs | Mandab | Shell Programming and Scripting | 7 | 03-15-2008 09:57 AM |
| (cont) Retrieve line from a file based on a value in specific column | efernandes | UNIX for Dummies Questions & Answers | 0 | 01-27-2007 01:00 PM |
| Retrieve line from a file based on a value in specific column | efernandes | UNIX for Dummies Questions & Answers | 1 | 01-27-2007 11:04 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
4 column tsv file, output 1 specific column
Hello all
siteexplorer.search.yahoo.com can output results in tsv format, when opened in excel I get 4 columns. I would like to wget that file, which I can do. I would then like to pull the 2nd column and output it only. I've searched around and found a few bits and pieces but nothing I've been able to get working as yet. If it matters I'm doing this on a Centos 5.1 machine. Any help would be great. Thanks |
|
|||||
|
So, if your input file was slightly different, you might not get your desired results with a 'plain' awk. See below where there is a single space between the month and a number:
Code:
> cat file66c.tsv
13 Oct 1 Joe smile
18 Jan 2 Linda laugh
11 Nov 3 Vets march
> cat file66c.tsv | tr "\t" "~" | cut -d"~" -f2
Oct 1
Jan 2
Nov 3
> cat file66c.tsv | awk '{print $2}'
Oct
Jan
Nov
|
|
||||
|
Thanks, the tr and cut command seems to be doing the trick. I did notice a few results missed the correct entry but this may be due to bad formating in the tsv file?
thanks Quote:
|
|
||||
|
Using awk in that way isn't going to work for the task, it's going to assume space is the seperator and if column 1 has more than 1 word etc it will get the wrong information.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|