Problem in Using fgrep Command with pattern file option


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem in Using fgrep Command with pattern file option
# 1  
Old 08-03-2011
Problem in Using fgrep Command with pattern file option

Hi,

i am using fgrep command with following syntax

Code:
fgrep -v -f pattern_file_name file

file contains few line and have the pattern which i am giving in pattern file.

My Problem is :
its is not giving any output.

while i am using fgrep -f pattern_file_name file

it is showing all lines of file.


this was the case of Cshell, if i run these command in tclsh

then (fgrep -v -f pattern_file_name file) command giving exception like -child process exited abnormally.

please provide me a solution of this problem.

Thanks

Last edited by radoulov; 08-03-2011 at 09:35 AM.. Reason: Code tags.
# 2  
Old 08-03-2011
I believe the only cause is wrong patterns in your "pattern_file_name". But I could be wrong of course.
# 3  
Old 08-03-2011
I tried in CSH and the same worked for me OK.

Code:
 
cat rem
aa bb
gg
dd ff

cat rem1
ss ddd aa bb ff gg
dd ff ff ff fff
dsds
dsd
agdsgs

 
TESTBOX> fgrep -f rem rem1
ss ddd aa bb ff gg
dd ff ff ff fff
TESTBOX> fgrep -v -f rem rem1
dsds
dsd
agdsgs

post the sample i/p and o/p from your system.
# 4  
Old 08-03-2011
Thanks Panyam

I used same file which you have shown in ur thread but still ...

cat file ----
ss ddd aa bb ff gg
dd ff ff ff fff
dsds
dsd
agdsgs

cat filter1
aa bb
gg
dd ff

Output for the command ---fgrep -f filter1 file
it is giving complete file
ss ddd aa bb ff gg
dd ff ff ff fff
dsds
dsd
agdsgs

output for the command ---fgrep -v -f filter1 file

it is not printing anything

so what may be the problem with me ?

Thanks
# 5  
Old 08-03-2011
Looks odd!!..

Is it a simple "grep" working?

try with grep -f option and see.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Need to use fgrep and egrep in a single command

I have a source file which is something like : C/*M/ / ***HMACCT ** MONTH FOR CURRENT MINUS 14 CAL DAY C/*D/ / ***HMACCT ** DAY FOR CURRENT MINUS 14 CAL DAY C/*X/ / ***HMACCT ** CENTURY FOR CURRENT MINUS 14 CAL DAY C/*Y/ / ***HMACCT **... (5 Replies)
Discussion started by: gotamp
5 Replies

2. Solaris

-w option in fgrep for Solaris

I want to use fgrep for a word serch ignoring case and it should dispaly word count along with the file name. I m using below code fgrep -wci string filenames But it is giving error Usage: fgrep pattern_list fgrep ... ... I have checked the man page... (11 Replies)
Discussion started by: millan
11 Replies

3. Shell Programming and Scripting

fgrep command: Perl programming help needed..Kindly advise

Hi, I am novice in PERL enviornment. I have a text files withso many entries in rows and columns. I have to pick up entries named as "Uniprot ID" in the file and create a new text file with list of particular Uniprot ID entries. Can anybody guide regarding this.. I came to know abut fgrep... (1 Reply)
Discussion started by: manigrover
1 Replies

4. Homework & Coursework Questions

trouble understanding file option and command line arguments

Hi, I am creating a program with the C language that simulates the WC command in Unix. My program needs to count lines, bytes and words. I have not added the code to count bytes and words yet. I am having trouble understanding what the file option/flag '-' does. I can not visualize how it moves... (1 Reply)
Discussion started by: heywoodfloyd
1 Replies

5. UNIX for Advanced & Expert Users

fgrep - printing pattern and filename

Hi, I have a patternfile with following pattern cat dog cow pig Let's say I have thousand files file0001 file0002 file0003 . . . file1000 Each pattern can occur multiple times in multiple files. How can I search for pattern so the output of pattern and the filename is printed... (1 Reply)
Discussion started by: yoda9691
1 Replies

6. Shell Programming and Scripting

Problem with -c option in Mailx command

Hi, I am using mailx command in shell script. When i put -c option for CC , i get error message as "Unknown flag: -c" . I checked manual of mailx command and found that ~c to be used but after using ~c also it is not working. My shell is Korn. Kindly let me know what i have to do . Thanks (9 Replies)
Discussion started by: krishna_gnv
9 Replies

7. Shell Programming and Scripting

Problem in file usage option

Hi, I have a dout in -u option in ls command. If we give ls -lt command it will dispaly the last modfied time. If we give ls -lu command it will display the last usage time of the file. My doubt here is Please refer the below commands. /appldata/rsc/dm/RejectData$ls -lt... (6 Replies)
Discussion started by: puni
6 Replies

8. Shell Programming and Scripting

fgrep command

How can we use fgrep command to search pattern on perticular field on a file. eg : I have a parren file having format cat patternfile SPA16S199982 SPA5S26330 I want to seach these pattern on FIRST field of File2(since other field has same data) and that too maching entirely. ... (10 Replies)
Discussion started by: morbid_angel
10 Replies

9. UNIX for Advanced & Expert Users

Problem with Carbon copy (CC) option in mailx command

Hi, I have problems with the cc option in mailx command. Just went through some of the similar threads but none provides a satisfactory explanation. I have a script using the mailx command in the following way: (echo `cat mailsub.txt` ; uuencode attachment.csv attachment.csv) | mailx -s... (2 Replies)
Discussion started by: SmithaN
2 Replies

10. UNIX for Dummies Questions & Answers

Usage of fgrep -f command in kshell

Hi, Can I know the usage of fgrep -f command in kshell. Reqirement: Need to search for list of patterns in list of files and display all the files which are having atleast one in the patterns list. I hope fgrep -f will serve this purpose within a loop. But I am not successfull in doing this.... (0 Replies)
Discussion started by: divv
0 Replies
Login or Register to Ask a Question