Sample Header Ad - 728x90

How can I use an argument from xargs to evaluate another expression?

1 vote
3 answers
2406 views
I would like to evaluate a basename expression given an argument from xargs. I tested:
find . -name '*.txt' | xargs -I f cp f DIR_OUT/copied_$(basename f)
which gives no file or directory because $(basename f) was not evaluated correctly. I may split it two steps: copying and changing the filename, but I would like to learn how to evaluate an expression with an argument from xargs.
Asked by Change-the-world (111 rep)
Feb 12, 2019, 07:24 AM
Last activity: Mar 19, 2021, 12:23 AM