Operating System - HP-UX
1831233 Members
2665 Online
110021 Solutions
New Discussion

using grep -v for files that END in .r

 
Chad Brackmann_1
Occasional Contributor

using grep -v for files that END in .r

I'm using grep -v to exclude certain files from being backed up.

I'm piping my filelist thru grep -v "\.r" which seems to exclude the files that I want excluded -- files ENDING in .r e.g. oe100.r , but it is also excluding files that have .r in the middle, e.g. foo.r.enable.

I've tried grep -v "\.r\n" , but that isn't filtering our anything

-- Chad
5 REPLIES 5
c_51
Trusted Contributor

Re: using grep -v for files that END in .r

give

grep -v "\.r$"

a try
David DeWitt_2
Frequent Advisor

Re: using grep -v for files that END in .r

Chad,

I believe you need the "$" to anchor it to the end of the line/filename.

Try:

grep -v "\.r$"

That should do it. If not I can find what will.

-dave
A. Clay Stephenson
Acclaimed Contributor

Re: using grep -v for files that END in .r

You need to invoke enhanced grep via -E and suplly an anchor ("$") to match only at the end of the line.
grep -E -v '\.r$' should exclude the files for you.
If it ain't broke, I can fix that.
David DeWitt_2
Frequent Advisor

Re: using grep -v for files that END in .r

Clay,

Does the "-E" requirement vary from system to system? On my system it appears to be unnecessary.

-dave
RAC_1
Honored Contributor

Re: using grep -v for files that END in .r

Why grep -v??

do ll /dir/![a-zA-Z]*.r

Anil
There is no substitute to HARDWORK