Modifying replace string in xargs

前端 未结 8 1353
梦毁少年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条回答
  •  梦毁少年i
    2021-01-30 02:24

    The following command constructs the move command with xargs, replaces the second occurrence of '.' with '.bar.', then executes the commands with bash, working on mac OSX.

    ls *.txt | xargs -I {} echo mv {} foo/{} | sed 's/\./.bar./2' | bash
    

提交回复
热议问题