Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • __sequence
    Member
    • Jun 2011
    • 13

    Print selected columns from a text file

    [I have already found the answer, see below]

    Hi all,

    I am looking for a simple oneliner (preferably) to print only selected columns (given by their column numbers) from a tab separated text file. Could you please suggest a command?

    Thanks!

    Answer

    awk -v OFS='\t' '{ print $1, $2, $4 }' old_file> new_file
    Last edited by __sequence; 10-17-2017, 01:07 PM. Reason: solved
  • neavemj
    Member
    • Feb 2014
    • 58

    #2
    You could also consider:

    cut -f 1,2,4 old_file > new_file

    Comment

    Latest Articles

    Collapse

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by SEQadmin2, 06-09-2026, 11:58 AM
    0 responses
    24 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 06-05-2026, 10:09 AM
    0 responses
    29 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 06-04-2026, 08:59 AM
    0 responses
    39 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 06-02-2026, 12:03 PM
    0 responses
    61 views
    0 reactions
    Last Post SEQadmin2  
    Working...