Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 05-11-2012, 10:05 AM   #1
LQ Newbie
Registered: May 2012
Posts: 5

Rep: Reputation: Disabled
Creating a condensed table from a pre-existing table in putty

I'm working with putty on Windows 7 professional and I'd like to know if there's a way to gather specific lines from a pre-existing table and make a new table with that information.

More specifically, I'd like the program to look at a specific column, say column N, and see if any of the rows in the column contain specific words (i.e. from this_is_what_i'm_looking_for, I'd like to to find all the rows in the colum that contain this_is), and print all these rows in a new table that I can save.

I can do this using Excel, but I'd like to know if there's a way to do it using putty.

Thank you.
Old 05-11-2012, 10:17 AM   #2
Ser Olmy
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 3,347

Rep: Reputation: Disabled
It's not very clear what you're asking here (at least not to me).

Are you using putty to connect to a Linux system from Windows 7? What sort of "table" are we talking about here? A text file?
Old 05-15-2012, 02:59 PM   #3
LQ Newbie
Registered: May 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
I figured out what to do in order to make my program do what I want it to do:

vi (gets you to the VIM program)

e: filename.txt (opens up the text file you want to manipulate)

:%g!/searchwords/d (looks for the words you are searching for in your document, and deletes any row that doesn't contain this information)

:w newfilename.txt (saves the information left over (the info you are looking for) as a new text file)

So, let's say this is my newfilename.txt document:

1234 someinfo1 moreinfo1, 1235
1236 someinfo2 moreinfo2, 1238
1239 someinfo3 moreinfo3, 5793

and I have some other text file called othertextfile.txt that looks like this:

1235 someinfo4 moreinfo4
1238 someinfo5 moreinfo5
5793 someinfo6 moreinfo6

and I want my program to go through newfilename.txt and look at all the numbers found in the third column of the first file (1235, 1238, 5793) and output the corresponding 3rd column in the second file, for each one

the third column of the first file has the numbers 1235, so it would find 1235 in the second file and output 1235 moreinfo4.

I'd like to continue using vi if possible

Thank you
Old 05-16-2012, 11:07 AM   #4
Ser Olmy
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 3,347

Rep: Reputation: Disabled
It may be possible to do this in vim, but what you describe is really a job for join. In fact, this is pretty much exactly the kind of operation join was designed to perform:

join -1 4 -2 1 -o "1.4 2.3" newfilename.txt otherfile.txt
The parameters mean:
-1 4 -2 1: Compare the fourth field in the first file with the first field in the second file.
-o "1.4 2.3": Output the contents of the fourth field from the first file and the third field from the second file.
newfilename.txt: The name of the first file is "newfilename.txt"
otherfile.txt: The name of the second file is "otherfile.txt"
If you want the results stored in a file rather that shown onscreen, just redirect the output to a file with the > operator (> results.txt).

For this to work, both input files must be sorted by the columns you're comparing against. sort can to that for you.


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
[SOLVED] iproute2 in Debian lenny adds routes to the main table instead of desired table donalbane Linux - Networking 3 03-28-2012 11:01 AM
LXer: KDE Table Spark Now Available For Pre-order LXer Syndicated Linux News 0 02-19-2012 02:00 PM
access paging table memory using another page table via MMU? valpa Linux - Kernel 8 08-26-2008 03:26 PM
Installing 10.2 using an existing partition table mike_savoie Slackware - Installation 7 04-12-2006 05:51 AM
How to import MS ACCESS Table including OLE filed into the MySQL Table ? myunicom Linux - General 1 11-28-2003 11:30 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:51 PM.

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