[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Need scripting or redirection help in BASH



On Mon, 07 Jan 2002 02:01:36 -0600
Gary Turner <kk5st@swbell.net> wrote:
> A day or two ago, I noticed that somewhere in my effort to get
> acquainted with my Debian box, a few hundred files of type 'c'
> (character, as opposed to regular or block) had shown up in my home
> directory.  All were created 12/21/01.  My wish is to be rid of them. 
> I did:
> 
> $ ls -l | grep "Dec 21" | less

Instead of using 'ls', I would suggest you use 'find' instead;

> and inspected the lot.  There should be a way to delete these files
> using grep and redirection/piping or a shell script.  My thought is
> some kind of iterative script, in pseudo code:
> 
> for x in ( ls -l | grep "Dec 21" )
>     do 
>         rm x( suitably parsed )
>     done

So, with 'find', it would be:

for i in $(find ./ -type c)
  do
   rm "$i"
  done

--
 .--=====-=-=====-=========----------=====-----------=-=-----=.
/    David Barclay Harris            Aut agere, aut mori.      \
\        Clan Barclay              Either action, or death.    /
 `-------======-------------=-=-----=-===-=====-------=--=----'

Attachment: pgpkOsX6FC2pq.pgp
Description: PGP signature


Reply to: