09-04-2012
Quote:
Originally Posted by
gimley
Hello,
I have a text file which contains a list of strings which I want to grep from another file where these strings occur and print out only these lines.
I had earlier used the grep command
where File1 was the file containing the strings to be grepped (Source File) and File2 the Target File from which the strings had to extracted.
And this had worked, but this time the above syntax does not work.
I am in a windows environment and tried both GREP for DOS as well as GREP32 but in each case I do not get the desired results.
Any help would be appreciated since the amount of strings to be grepped is quite large.
You say that you're looking for strings, but with the options you've given you're not looking for fixed strings; you're looking for matches to basic regular expressions contained in File1. If you want fixed strings, you need to add the -F option as in
grep -F -f File1 File2. If this doesn't solve your problem, we need to know what the contents of File1 and File2 look like, and any messages you're getting when you run the command. If you're running in a Windows environment, where are you getting your grep and grep32 utilities?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi ,
a:) i have configuration file with pattren
<Range start no>,<Range end no>,<type of records to be extracted from the data file>,<name of the file to store output>
eg:
myfile.confg
9899000000,9899999999,DATA,b.dat
9899000000,9899999999,SMS,a.dat
b:) Stucture of my data file is... (3 Replies)
Discussion started by: suparnbector
3 Replies
2. Shell Programming and Scripting
Dear Friends,
I have a flat file from which I want to grep line no. 7,10, 19 to 35, 37.
How can it be done?
Thank you in advance
Anushree (6 Replies)
Discussion started by: anushree.a
6 Replies
3. Shell Programming and Scripting
OK I will do my best to explain what I need help with.
I am trying to format an ldif file so I can import it into Oracle oid.
I need the file to look like this example. Keep in mind there are 3000 of these in the file.
changetype: modify
replace: userpassword
dn:... (0 Replies)
Discussion started by: timothyha22
0 Replies
4. Shell Programming and Scripting
I have a .kml file. So I want filter the .kml to get only the tags that have this numeric codes that they are in a text file
11951
11952
74014
11964
11965
11969
11970
11971
11972
60149
74018
74023
86378
11976
11980
11983
11984
11987 (5 Replies)
Discussion started by: pcoj33
5 Replies
5. UNIX for Dummies Questions & Answers
Hi!
I recently downloaded a wordlist file called 2of12.txt, which is a wordlist of common words, part of the 12dicts package. I've been getting unexpected results from grepping it, such as getting no matches when clearly there ought to be, or returns that are simply wrong.
Par exemple:
egrep... (4 Replies)
Discussion started by: sudon't
4 Replies
6. Shell Programming and Scripting
Hello,
I have a file with a large number of words each listed in sequential order one word per line.
I want to search these words in another file which has the structure
Both the files are large, but the words in the sourcefile are all available in the target file.
I tried to grep... (2 Replies)
Discussion started by: gimley
2 Replies
7. Shell Programming and Scripting
Hello,
I have a data in file 1
2000000024776
2000000026979
2000000033355
2000000036309
2000000041291
2000000042679
2000000067221
and in file 2 its like this
2000000024776 16
2000000026979 16
2000000033355 16 (2 Replies)
Discussion started by: mirwasim
2 Replies
8. Shell Programming and Scripting
Hi,
I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file.
File1 - file2 = file3
wc -l file1.txt
58112
wc -l file2.txt
55260
head -5 file1.txt
101214200123
101214700300
101250030067
101214100500... (10 Replies)
Discussion started by: Divya Nochiyil
10 Replies
9. Shell Programming and Scripting
I have a lot of files with keywords and unique names. I'm using a shell script to refer to a simple pattern file with comma separated values in order to match on certain keywords. The problem is that I don't understand how to handle the wildcard values when I want to skip over the unique names.
... (5 Replies)
Discussion started by: abercrom
5 Replies
10. Shell Programming and Scripting
Hi There, Good Day !!
I have txt file containing data in the below format. There are many lines, here i have mentioned for example.
cat remo.txt
2/3/2017 file1
3/4/2016 file2
6/6/2015 file5
1/1/2018 file3
4/3/2014 file4
-
-
-
I need to grep the file names for given date rage... (11 Replies)
Discussion started by: kumar85shiv
11 Replies
ZGREP(1) General Commands Manual ZGREP(1)
NAME
zgrep - search possibly compressed files for a regular expression
SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename...
DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code:
(-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the
standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep.
If the GREP environment variable is set, zgrep uses it as the grep program to be invoked.
EXIT CODE
2 - An option that is not supported was specified.
AUTHOR
Charles Levert (charles@comm.polymtl.ca)
SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1)
ZGREP(1)