Re: BASH file processing help

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

 



this writes exactly as you say it

cd /where/to/keep
for file in $(ls -1)
do
	[ -f /where/to/delete/$file ] && rm /where/to/delete/$file
done

this only works at one level (it doesn't process sub-directories)

btw find as a -printf option with which you can format the output as
desired (for example keeping only the name of the file, not its path). rtfm
"man find"

hth


A 15:33 17/11/2003 -0600, vous avez écrit :
>I have been trying to complete a simple (for me on the WinBlows platform)
file 
>operation and seem unable to do so.  Basically I need something along the
lines 
>of "For all files in a given directory, delete files with the same name from 
>this other directory".  I tried using find with exec but that causes me
grief 
>because it adds the current path to the file name to be deleted.  I tried
using 
>a for look but cannot seem to get it to work from the command line, without 
>putting it in a script file.


-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux