-v and -f option for grep not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting -v and -f option for grep not working
# 1  
Old 06-01-2013
-v and -f option for grep not working

In solaris, i m trying to find the files having a particulat extension and then from the list i want to exclude those files which is present in a file.

But it seems the -f and -v option are not working

Code:
 
find $source -type f -name $extn | /usr/xpg4/bin/grep -F -v -f $exclude | while read filename
 
do 
 
echo $filename
 
done

# 2  
Old 06-01-2013
Grep -v and -f is not working

In solaris, i m trying to find the files having a particulat extension and then from the list i want to exclude those files which is present in a file.

But it seems the -f and -v option are not working




Code:
 
find $source -type f -name $extn | /usr/xpg4/bin/grep -F -v -f $exclude | while read filename 
do 
echo $filename
 done

# 3  
Old 06-01-2013
How could anyone guess what files are under $source, what the $extn variable contains and what the $exclude file contains ?

Please provide more details about what makes you feeling these options do not work.
# 4  
Old 06-01-2013
$source="/usr/var/SA"
$extn="*.pll"
$exclude="a.txt"
$exclude is the file name which contains name of the file those will be excluded.
# 5  
Old 06-01-2013
Please provide some evidence the options do not work.
# 6  
Old 06-01-2013
Quote:
Originally Posted by millan
In solaris, i m trying to find the files having a particulat extension and then from the list i want to exclude those files which is present in a file.

But it seems the -f and -v option are not working




Code:
 
find $source -type f -name $extn | /usr/xpg4/bin/grep -F -v -f $exclude | while read filename 
do 
echo $filename
 done

Since you don't show us how source, extn, and exclude are set and you haven't shown us the contents of the file named by the expansion of $exclude, this is just a guess. But I think it is highly likely that your problem is the find command; not the grep command.

I'm guessing that if you're looking for files with the extension ".c" you have set extn to ".c" and your find isn't finding any files named ".c". Try changing the find statement to:
Code:
find $source -type f -name "*$extn"

If that doesn't fix your problem, you're going to have to supply a lot more detail about what all of these variables contain, what files exist in the file hierarchy rooted at $source, and what is in the file named by $exclude.
# 7  
Old 06-01-2013
Two threads merged. Sorry for the confusion.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Maxdepth option of find command not working

Can you please figure out what is the issue here $ find . -maxdepth 1 -type f -size 0 -print find: bad option -maxdepth please find the OS details $ uname -a HP-UX g5u1216 B.11.31 U ia64 2614088426 unlimited-user license Use code tags, thanks. (6 Replies)
Discussion started by: TomG
6 Replies

2. AIX

SQLPLUS -S option not working

Hi All, I am using the following script to run some sql on database but i am not getting the result. When i tried the same by removing "-s" option it is working fine but getting other things as well with my input as shown below. Can anyone please suggest why "-s" option is not working in AIX and... (2 Replies)
Discussion started by: ssk250
2 Replies

3. Shell Programming and Scripting

Egrep not working with -f option

Hi, I am trying to find out patterns in file 1 using patterns stored in file 2. Following is the code FILE1=inputfilename FILE2=blacklist blacklist 1203 97715555 20afEOF egrep -f $FILE2 $FILE1 but the above code is not working either using egrep or grep. Just for your... (10 Replies)
Discussion started by: siramitsharma
10 Replies

4. UNIX for Dummies Questions & Answers

~c is not working properly with -r option

Hi There, --------- file1 ------- ~c asd@ac.com -------------- Now i am using below command cat file1|mailx -s " testing" -r " My Name" abc@tech.com (3 Replies)
Discussion started by: Tapan Sharma
3 Replies

5. HP-UX

who command option not working

Running HP 11.31 on a HP3600. But when I log in as a user the who command works but if I use an option like "who -m" I get nothing. Any thoughts on what is causing this problem. (11 Replies)
Discussion started by: KMRWHUNTER
11 Replies

6. Solaris

noatime option is not working with mount

Hi Gurus, I mount a filesystem with -o noatime option to avoid getting the recording of time into the inode, however as on when i am doing any chnage in any file create in this file system the timestamp of the file is changing, whcih i can see with ls -l :(. What can be the reason ? i... (4 Replies)
Discussion started by: kumarmani
4 Replies

7. UNIX for Dummies Questions & Answers

Urgent -Please help me 'mail' option not working

Hi , I have already posted a post regarding this, but i didn't get my problem solve, so some body help me as it was urgent for me, my mail option is not working, when i send a mail, it is strucking in /var/spool/mqueue folder. and i am getting struck there itself, i see below two files are... (1 Reply)
Discussion started by: mars_girish9
1 Replies

8. UNIX for Advanced & Expert Users

For ls command,-r option is not working on OSF1

There r 2 servers. Lets call them S1 and S2.. S1 is OSF1 and S2 is SunOS.. One directory of S2 is mounted on S1. say abc/xyz There is one application which continuously put xml files in that directory (on S2). If we give command “ls -lrt” on S2 it gives proper output.. (i.e. gives list... (1 Reply)
Discussion started by: asmita
1 Replies

9. UNIX for Dummies Questions & Answers

-d option not working...

:confused: In the following, when I enter a valid, existing directory,why am I getting Not Found when the Dir DOES exist? read auser echo "You entered $auser" wait 2 cd /home if then echo "Dir Exists" sleep 2 else echo "/home/$auser Not Found" sleep... (2 Replies)
Discussion started by: rgouette
2 Replies

10. Solaris

Why does the 'ps' command with -u option not working?

How can I use the 'ps' command to view current sessions but only for a given process/user, with the -u parm? In older versions of Unix, this used to work, but not in Sun Solaris. Thanks (4 Replies)
Discussion started by: ElCaito
4 Replies
Login or Register to Ask a Question