LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-19-2015, 04:47 AM   #1
kirteshmiet
LQ Newbie
 
Registered: Apr 2015
Posts: 1

Rep: Reputation: Disabled
How to print different colums of different files in one file.


Hi All,

I want to print different colums of different files in one file as the orignal column position by using linux commands such as sed awk etc. here is the example i am giving please help.

Suppose i have one file 1.txt as
1 2 3 4
1 2 3 4

and i have another file 2.txt as
5 6 7 8
5 6 7 8

so i want to print column 1 from 1.txt and column 3 from 2.txt in a different file.

and output file should look like this
1 7
1 7

thanks a lot.
 
Old 04-19-2015, 05:09 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Sounds like a plan ... what have you tried?
 
Old 04-19-2015, 10:54 AM   #3
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,881

Rep: Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660
Quote:
Originally Posted by kirteshmiet View Post
... and output file should look like this
Code:
1 7
1 7
Consider using paste to combine the files and then cut to isolate the desired columns.

Daniel B. Martin

Last edited by danielbmartin; 04-20-2015 at 12:04 PM. Reason: Improved advice
 
  


Reply



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
read three files and print output in a new file kvtspavan Linux - Newbie 17 09-10-2010 06:43 AM
How to print/save a bundle of .png files as a single .pdf file satimis Linux - Software 24 08-04-2007 06:05 AM
I need to tail -f just a few colums o a text file ericcarlson Linux - General 3 01-30-2007 03:07 PM
Print-to-file print driver to print PDF Bill Fox Linux - General 3 05-02-2006 04:15 PM
i want to print all the files in a directory and the file size in a same line naveen245 Programming 3 12-06-2005 08:22 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:17 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
Open Source Consulting | Domain Registration