LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-03-2014, 01:11 PM   #1
javaer
LQ Newbie
 
Registered: Dec 2010
Posts: 6

Rep: Reputation: 0
Split tab delimited files


Hello, I have a file in this format with two tabs:

A B This is good.
...

How can I split this file line by line into two files, the first containing the first two columns and the second containing the last column?

Thank you.
 
Old 02-03-2014, 02:12 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
awk could be a choice:
Code:
awk 'BEGIN{FS=OFS="\t"}{print $1,$2 > "file_one"; print $3 > "file_two"}' file
 
Old 02-03-2014, 02:28 PM   #3
javaer
LQ Newbie
 
Registered: Dec 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks. I will try.
 
  


Reply

Tags
split


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
searching pattern in tab delimited file using grep vaibhavs17 Programming 5 03-05-2010 01:02 AM
Split a delimited string into multiple strings... leeharris Programming 10 02-07-2009 06:10 AM
Working with Tab-Delimited files shiroh_1982 Linux - Newbie 5 06-02-2006 04:08 AM
Parsing a tab delimited text file jajanes Programming 9 08-08-2003 10:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration