Re: basic command pipe question



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Don Russell wrote:
I need some basic CLI help. :-) I've googled, and read, and I can't
find how to erase a bunch of files in one go.

Specifically, I need a command that will erase *.zip files,
regardless of the text case of the .zip part....

So far, I have
ls | grep -iE \\.zip$

That gives me the correct list of files.... but I don't know how to
get rm to process that list.. It doesn't look like rm has an option
to read the file name from stdin, it's expecting the file name as a
CLI argument.

This is one of those things that you could do a whole lot of ways and
I'm sure more than a few people will provide options. I'm looking
forward to learning a few new things out of this too (it always
happens, no matter how well I think I know the possibilities :).

Here are a few ways:

ls | grep -iE \\.zip$ | xargs rm -f

You could use find instead of ls and grep too. This example is
almost straight from the xargs man page:

find -iname '*.zip' | xargs rm -f

Or, using some bash command substitution:

rm -f $(ls | grep -iE \\.zip$)

Of course, it's best to run these without the -f option or only on a
copy of your files until you're sure that it works as you expect it to
work.

I know this is basic stuff.... I'm obviously missing some fundamental
concept of command line processing. :-)

You're just missing a few new commands in your mental storage. With
many thousands of them, it takes a long time to learn and remember the
myriad ways things can be used. :)

- --
Todd OpenPGP -> KeyID: 0xD654075A | URL: www.pobox.com/~tmz/pgp
======================================================================
(When asked whether he liked children) "Ah yes...boiled or fried."
-- W.C. Fields

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: When crypto is outlawed bayl bhgynjf jvyy unir cevinpl.

iG0EARECAC0FAkSV0QEmGGh0dHA6Ly93d3cucG9ib3guY29tL350bXovcGdwL3Rt
ei5hc2MACgkQuv+09NZUB1pSGACglKHfwEcCzOOU9bIzZLtPkaF/3McAoMzuvhAF
x0kQRdAQK9RUqtBqS6Gn
=qzxa
-----END PGP SIGNATURE-----

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list



Relevant Pages

  • Re: xp_cmdshell default path (system32) problem
    ... purge all files from a given directory. ... that xp_cmdshell ALWAYS executes under the security context of defined ... I'm use xp_cmdShell to execute "erase" command like ... I haven't executed the actual erase statements yet but rather have been ...
    (microsoft.public.sqlserver.programming)
  • Re: basic command pipe question
    ... =>to erase a bunch of files in one go. ... will execute a seperate process for *EACH* file to be deleted and would potentially overflow before the for loop even starts. ... Although, if I understand properly what's happening here, the pipe solution allows files to be erased as they are found in the filelist, while the gobbing method first requires that all files that match be found, then each command is executed one after another. ...
    (Fedora)
  • Re: xp_cmdshell default path (system32) problem
    ... I'm use xp_cmdShell to execute "erase" command like commands to delete the files. ... I haven't executed the actual erase statements yet but rather have been running test where I just perform a DIR instead of a ERASE to confirm what WILL get deleted when I do it for real. ... The problem is, if the directory that I supply doesn't exist, then the command appears to opporate on the "default path". ... However, this doesn't protect me later when my script is running as a scheduled job and some unssuspecting sole happens to delete, rename or change the security settings on my directory and now the next time the job runs I crush SYSTEM32! ...
    (microsoft.public.sqlserver.programming)
  • Re: xp_cmdshell default path (system32) problem
    ... I'm use xp_cmdShell to execute "erase" command like commands to delete the files. ... I haven't executed the actual erase statements yet but rather have been running test where I just perform a DIR instead of a ERASE to confirm what WILL get deleted when I do it for real. ... The problem is, if the directory that I supply doesn't exist, then the command appears to opporate on the "default path". ... However, this doesn't protect me later when my script is running as a scheduled job and some unssuspecting sole happens to delete, rename or change the security settings on my directory and now the next time the job runs I crush SYSTEM32! ...
    (microsoft.public.sqlserver.programming)
  • BR330T Hidden commands
    ... My finger hurts but here's all the command i found: ... Beware, some commands will erase your systems, make very loud ... 3- DUMP TEST (ask for memory address) ... 6- Key touch test ...
    (rec.radio.scanner)