This command will do what I want to do, almost
# find ./ -name picasa.ini | xargs rm
When I delete one, I would like it to show on stdout, like "/path/to/
picassa.ini"
I would appreciate any suggestions.
TIA
Owen
You might find that you rm has a -v option:
find ./ -name picasa.ini | xargs rm -v
or that you have a device called /dev/stderr that means you can do this:
find ./ -name picasa.ini | tee /dev/stderr | xargs rm
Neither of this is portable across a wide range of systems, but then you
may not need that for this simple action.
--
Ben.
If you use xargs everything on stdout will be processed. What you are
looking for is the tee(1) command and writing to the terminal; basically
something like
find . -name picasa.ini | tee /dev/tty | xargs rm
>>
>> I would appreciate any suggestions.
>
> You might find that you rm has a -v option:
>
> find ./ -name picasa.ini | xargs rm -v
>
> or that you have a device called /dev/stderr that means you can do this:
>
> find ./ -name picasa.ini | tee /dev/stderr | xargs rm
>
> Neither of this is portable across a wide range of systems, but then you
> may not need that for this simple action.
>
What complicated the matter is the OP's requirement to display /path/to/file.
To show the absolute path on /dev/tty there are a couple choices; e.g.
you can use process substitution and do all processing you like, as in
find . -name picasa.ini | tee >( awk '...' >/dev/tty ) | xargs rm
with an appropriate awk (or sed) command to substitute the absolute path
for the '.' at the place indicated by '...'. Maybe something like
find ... | tee >( awk -v p="$PWD" 'sub(/\./,p)' >/dev/tty ) | xargs rm
Or you may find the following code simpler and easier to understand
find ... | xargs printf "$PWD/%s\n" | tee /dev/tty | xargs rm
(The usual caveat: if you have pathological file names (instead of just
picasa.ini) in your search hierachy you can make severe damage, especially
if you invoke such commands as root; the command prompt '#' is a hint that
the OP might be doing that.)
Janis
How about: find ./ -name picasa.ini -exec rm {} \; -print
This will print each path to as the file is removed.
--
..!sdf.org!martians / SDF Public Access UNIX System / http://sdf.org
Thanks,
find ./ -name picasa.ini -exec rm {} \; -print
worked like a charm.
owen@owen-desktop:/mnt/sdb10/My_Pictures$ find ./ -name picasa.ini -
exec rm {} \; -print
./Ged's Funeral/picasa.ini
./Coffee and Chat/picasa.ini
./Midweek Rides/picasa.ini
./Bicycle Rides/picasa.ini
./Binalong 2005/picasa.ini
Using the "xargs rm" failed outside the directory, the error message I
received was;
owen@owen-desktop:/mnt/sdb10/My_Pictures$ find ./ -name picasa.ini |
xargs rm
xargs: unmatched single quote; by default quotes are special to xargs
unless you use the -0 option
owen@owen-desktop:/mnt/sdb10/My_Pictures$ find ./ -name picasa.ini |
xargs -0 rm
rm: cannot remove `./Ged\'s Funeral/picasa.ini\n./Coffee and Chat/
picasa.ini\n./Midweek Rides/picasa.ini\n./Bicycle Rides/picasa.ini\n./
Binalong 2005/picasa.ini\n': No such file or directory
(where did that \n come from?)
Thanks for your help, several hundred picasa.ini files deleted
Owen
Your xargs -0 probably requires a find ... -print0