1837097 Members
2235 Online
110112 Solutions
New Discussion

grep script

 
SOLVED
Go to solution
Duffs
Regular Advisor

grep script

Hi,

I am having some difficulty writing a script for the following requirement:

The script needs to be able to search only "WWI*MAN*" files within a certain dir and from these files rcp the ones which contain certain lines beginning with '3' and also contain 'TIL' (in the same format as my attached file) to another network server.

Big points for anyone can help with this.

Cheers.

p.s. my attachment is only the mid section of the original file, it does not begin or end in this format.

3 REPLIES 3
Rodney Hills
Honored Contributor
Solution

Re: grep script

cd /your/directory
grep -l "^3.*TIL" WWI*MAN* -exec rcp {} othrsrvr:/tmp/{} \;

HTH

-- Rod Hills
There be dragons...
Rick Garland
Honored Contributor

Re: grep script

Here is an example SED script I did some time ago that matches your description. Modify to fit your needs


Duffs
Regular Advisor

Re: grep script

Thanks lads,
That was just the help I was looking for.
Cheers.