TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [TCLUG:21204] Question on Bourne shell script.
If the list has a seperate directory on each line of baddirs.txt, do this:
cat baddirs.txt | xargs grep -v <stuff I don't want>
Gabe
On Mon, Sep 11, 2000 at 02:04:54PM -0500, Mike Glaser wrote:
> I am working on a shell script to run a tape backup for one of my servers and I
> have a small problem.
>
> Since I am using cpio, I first generate list of all files on the server with the find
> command. Then I want to go back and remove any directories that meet a
> certain pattern (like ' ^ \ /proc \ / ' ) that is included in another 'exclude' file. I
> thought of one way to do that using 'grep -v .... > somefile.txt'
>
> My problem is, how do I read in the list of excluded directories from a file and
> pass that to grep? I guess I don't understand redirection and shell
> programming enough to solve my problem. I could figure out a solution with
> Perl, but I must write te code in a bash script.
>
> This is what I have now, but it doesn't work...
> grep -v file.txt < cat exclude_list.txt > new_shorter_file.txt
>
> If anyone could help me out I would appreciate it!
> Thank-you,
> Mike Glaser
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tclug-list-unsubscribe@mn-linux.org
> For additional commands, e-mail: tclug-list-help@mn-linux.org
--
--------------------------------------------------------------------------------
Gabe Turner | X-President,
UNIX Systems Administrator, | Assoc. for Computing Machinery
U of M Supercomputing Institute for | Univerisity of Minnesota
Digital Simulation and Advanced Computation | dopp@acm.cs.umn.edu
"My dinosaur droppings! Painted like Easter eggs!"
- Ren Hoek in "Sven Hoek"
--------------------------------------------------------------------------------