Modifying replace string in xargs

前端 未结 8 1358
梦毁少年i
梦毁少年i 2021-01-30 01:43

When I am using xargs sometimes I do not need to explicitly use the replacing string:

find . -name \"*.txt\" | xargs rm -rf

In oth

8条回答
  •  太阳男子
    2021-01-30 02:17

    Inspired by an answer by @justaname above, this command which incorporates Perl one-liner will do it:

    find ./ -name \*.txt | perl -p -e 's/^(.*\/(.*)\.txt)$/mv $1 .\/foo\/$2.bar.txt/' | bash

提交回复
热议问题