Jul 22 2010, 11:54 PM
Post
#1
|
|
|
Whats this Lie-nix Thing? ![]() Group: Members Posts: 1 Joined: 22-July 10 Member No.: 15,618 |
i am trying to write a script (or use a command) that will grep each line from a file named Backlist which contains the titles of about 850 ebooks against another file named HQNlist which contains about 5500 lines which are book titles plus their corresponding ISBN codes. I want to be able to find those 850 matching titles and write them to a new file because I need to make a list of those ISBNs.
I wrote this script but it just writes the entire HQNlist to the new file: #!/bin/bash for line in `cat Backlist` do grep -i $line HQNlist >> results.omfg done Any ideas? Thanks in advance |
|
|
|
![]() |
Aug 11 2010, 02:09 PM
Post
#2
|
|
|
Whats this Lie-nix Thing? ![]() Group: Members Posts: 5 Joined: 11-August 10 From: England Member No.: 15,699 |
i am trying to write a script (or use a command) that will grep each line from a file named Backlist which contains the titles of about 850 ebooks against another file named HQNlist which contains about 5500 lines which are book titles plus their corresponding ISBN codes. I want to be able to find those 850 matching titles and write them to a new file because I need to make a list of those ISBNs. I wrote this script but it just writes the entire HQNlist to the new file: #!/bin/bash for line in `cat Backlist` do grep -i $line HQNlist >> results.omfg done Any ideas? Thanks in advance Yes, try looking at the contents of results.omfg After looking at the script I tried it myself and assuming that Backlist and HQNlist are in the same directory then then script works. The only thing to watch out for is duplicate entries where the title in Backlist is (eg) LOTR, and the HQNlist contains LOTR I, LOTR II and LOTR III as it will consider all three as hits. |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 9th September 2010 - 10:29 PM |