LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 06-22-2016, 02:42 PM   #1
Nasrin
LQ Newbie
 
Registered: Jun 2016
Posts: 2

Rep: Reputation: Disabled
re arranging rows according to sequence of a column in different file


I have file1 like this--

B 2
c 3
A 1

file2-

A aa
B bb
C cc

Output file3 I want is--

B bb
C cc
A aa

so file3 should have the sequence of the first column from file1, but the corresponding row of each of that column should same as file2.

TIA
 
Old 06-22-2016, 09:43 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,438

Rep: Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842
Great ... show us what you have done to solve this problem? Also might want to mention that the search is case insensitive seeing as you have 'c' in one file and 'C' in the other in column 1
 
1 members found this post helpful.
Old 06-23-2016, 01:09 AM   #3
Nasrin
LQ Newbie
 
Registered: Jun 2016
Posts: 2

Original Poster
Rep: Reputation: Disabled
I am very new in Linux, I was just thinking of using awk/sed first to separate the first column of file1 into file4 and then grep each row of file4 to get the whole line from file2. The search is not case sensitive. c and C are same here, sorry for the mistake though. am I thinking right?
 
Old 06-23-2016, 03:19 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,438

Rep: Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842
Give it a go and report back if you get stuck The beauty of your task is it will not affect anything on your system so no harm in trying what you like.
 
1 members found this post helpful.
Old 06-23-2016, 05:52 AM   #5
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US, Earth, end border$! ◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that works well on my cheapest; has been KDE or CLI but open... http://goo.gl/NqgqJx &c ;-)
Posts: 3,314
Blog Entries: 2

Rep: Reputation: 957Reputation: 957Reputation: 957Reputation: 957Reputation: 957Reputation: 957Reputation: 957Reputation: 957
Thumbs up :cool:

Quote:
Originally Posted by Nasrin View Post
I am very new in Linux, I was just thinking of using awk/sed first to separate the first column of file1 into file4 and then grep each row of file4 to get the whole line from file2. The search is not case sensitive. c and C are same here, sorry for the mistake though. am I thinking right?
YOLO

Hi.

The second link in my signature (i.e: "roots") will lead you to the Matrix and down some rabbit holes if you follow?

Have fun!

Last edited by jamison20000e; 06-23-2016 at 05:58 AM. Reason: changed "down a rabbit's hole" to: down some rabbit holes... ;-)
 
  


Reply


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
Extracting rows from one file based on column entries in another file mphillips67 Linux - Newbie 3 05-06-2014 06:26 PM
how to find match between two rows of column in same file using PERL genetist Linux - Newbie 3 07-13-2013 11:17 AM
[SOLVED] Rows to Column manipulation micyew Programming 12 07-12-2012 07:13 PM
Column into rows bharatbsharma Programming 1 10-25-2007 02:23 AM
Parsing rows and column data from a file using perl dav_y2k Programming 1 10-08-2006 11:57 AM


All times are GMT -5. The time now is 04:46 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