I have a directory, /original
, that has hundreds of files. I have a script that will process files one at a time and delete the file so it's not executed again if the script gets interrupted. So, I need a bunch of soft links to the files on /original
to /processing
. Here's what I tried:
find /original -name "*.processme" -exec echo ln -s {} $(basename {}) \;
and got something like:
ln -s /original/1.processme /original/1.processme ln -s /original/2.processme /original/2.processme ln -s /original/3.processme /original/3.processme ...
I wanted something like:
ln -s /original/1.processme 1.processme ln -s /original/2.processme 2.processme ln -s /original/3.processme 3.processme ...
It appears that $(basename)
is running before {}
is converted. Is there a way to fix that? If not, how else could I reach my goal?
You can also use cp
(specifically the -s
option, which creates symlinks), eg.
find /original -name "*.processme" -print0 | xargs -0 cp -s --target-directory=.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With