数据结构如下,我想将“lane-7”改为“lane-5”。 我正在考虑这样的命令,但它不起作用。
find PATH -name "lane-7*" | xargs -i echo mv {} `echo {}|sed 's/lane-7/lane-5/'` | sh
Anyidea?感谢
PATH/28/lane-7-22.fq
PATH/28/lane-7-21.fq
PATH/28/lane-7-18.fq
PATH/28/lane-7-24.fq
PATH/28/lane-7-23.fq
PATH/28/lane-7-19.fq
PATH/28/27/lane-7-22.fq
PATH/28/27/lane-7-21.fq
PATH/28/27/lane-7-18.fq
PATH/28/27/lane-7-24.fq
PATH/28/27/lane-7-23.fq
PATH/28/27/lane-7-19.fq
PATH/28/27/26/lane-7-22.fq
PATH/28/27/26/lane-7-21.fq
PATH/28/27/26/lane-7-18.fq
PATH/28/27/26/lane-7-24.fq
PATH/28/27/26/lane-7-23.fq
PATH/28/27/26/lane-7-19.fq
PATH/28/27/26/25/lane-7-22.fq
PATH/28/27/26/25/lane-7-21.fq
PATH/28/27/26/25/lane-7-18.fq
PATH/28/27/26/25/lane-7-24.fq
PATH/28/27/26/25/lane-7-23.fq
PATH/28/27/26/25/lane-7-19.fq
...
答案 0 :(得分:2)
您可以使用while
循环和bash字符串替换来执行此操作:
find PATH -name "lane-7*" | while read -r file ; do
echo mv $file ${file/lane-7/lane-8}
done
如果看起来不错,请移除echo
。
答案 1 :(得分:2)