How can I run a subcommand inside find's exec? For example, if I want to get the filename only from the full path and print it, I would fire,
find ./ -name "*.csv" -exec echo $(basename {}) \;
where the echo is parent command of child command basename.
But the result is same as this,
find ./ -name "*.csv" -exec echo {} \;
What should I do ?
This is what you are looking for:
find . -name "*.csv" -exec sh -c 'echo $(basename "$1")' sh {} \;
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