Cut the two column from non delimited file | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Cut the two column from non delimited file

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-15-2013
Wan Fahmi Wan Fahmi is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 15 January 2013, 8:16 AM EST
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Cut the two column from non delimited file

Hi, I have a question how to cut the column from non delimited file

This is my file


Code:
gene_id ENSG00000223972 transcript_id ENST00000456328 exon_number 1 gene_biotype pseudogene gene_name DDX11L1 transcript_name DDX11L1-002 tss_id TSS26614
gene_id ENSG00000223972 transcript_id ENST00000515242 exon_number 1 gene_biotype pseudogene gene_name DDX11L1 transcript_name DDX11L1-201 tss_id TSS165962
gene_id ENSG00000223972 transcript_id ENST00000518655 exon_number 1 gene_biotype pseudogene gene_name DDX11L1 transcript_name DDX11L1-202 tss_id TSS165964
gene_id ENSG00000223972 transcript_id ENST00000450305 exon_number 1 gene_biotype pseudogene gene_name DDX11L1 transcript_name DDX11L1-001 tss_id TSS72060
gene_id ENSG00000223972 transcript_id ENST00000450305 exon_number 2 gene_biotype pseudogene gene_name DDX11L1 transcript_name DDX11L1-001 tss_id TSS72060
gene_id ENSG00000223972 transcript_id ENST00000518655 exon_number 2 gene_biotype pseudogene gene_name DDX11L1 transcript_name DDX11L1-202 tss_id TSS165964

I want to cut only the 1st and 2nd column (gene_id, ENST#)

Thank you

Last edited by Scrutinizer; 01-15-2013 at 07:52 AM.. Reason: quote tags => code tags
Sponsored Links
    #2  
Old 01-15-2013
Scott's Avatar
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 23 September 2014, 9:13 PM EDT
Location: Zürich
Posts: 8,483
Thanks: 332
Thanked 1,047 Times in 914 Posts
If the fields are separated by a single space, then:

Code:
cut -d" " -f1-2 file

Otherwise it's simple with awk

Code:
awk '{print $1 FS $2}' file

I would add that this kind of question has been asked very many times, and you should search before asking. Thanks.
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
how to show particular column from pipe delimited file vai15517 Homework & Coursework Questions 1 05-07-2012 09:31 AM
Moving a column across a delimited data file ayan153 Shell Programming and Scripting 2 10-09-2011 10:47 AM
Extract second column tab delimited file shoaibjameel123 Shell Programming and Scripting 1 09-09-2011 05:28 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
To cut entire column from a file and apend it to another file as another column sakthifire Shell Programming and Scripting 4 06-25-2008 04:27 AM



All times are GMT -4. The time now is 10:24 PM.