Подскажите код, переименовать группу файлов?
К примеру, сейчас так:
Princess of the Dawn - Accept.mp3
Cradle Of Love - Billy Idol.mp3
Sweet Sixteen - Billy Idol.mp3
Livin On A Prayer - Bon Jovi.mp3
Runaway - Bon Jovi.mp3
The Unforgiven - Metallica.mp3
Send Me An Angel - Scorpions.mp3
Still Loving - Scorpions.mp3
Хочу так:
Accept - Princess of the Dawn.mp3
Accept - Time Machine.mp3
Billy Idol - Cradle Of Love.mp3
Billy Idol - Sweet Sixteen.mp3
Bon Jovi - Livin On A Prayer.mp3
Bon Jovi - Runaway.mp3
Metallica - Nothing Else Matters.mp3
Metallica - The Unforgiven.mp3
Scorpions - Send Me An Angel.mp3
Scorpions - Still Loving.mp3
P.S чем лучше это делать: sed, awk, rename, basename?
Система macOS.
主页
/
user-205197
031071's questions
我在互联网上找到了如何做到这一点:
basename -s .txt *.txt | xargs -n1 -i mv {}.txt {}.sh
xargs: illegal option -- r
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
[-L number] [-n number [-x]] [-P maxprocs] [-s size]
[utility [argument ...]]
我在habr上找到了一个选项:
ls | sed -e "p;s/.txt/.sh/" | xargs -2 -fmv
xargs: illegal option -- 2
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
[-L number] [-n number [-x]] [-P maxprocs] [-s size]
[utility [argument ...]]
rename 's/.txt/.sh/g' *.txt
-bash: rename: command not found
man rename - open 我做错了什么?PS OS X 系统
再会!
有一个文件:test.txt
- 啊啊啊啊
- 万维网
- cccccccc
- dddddddddd
- eeeeeeee
- 呸呸呸呸
你需要这样做并保存它。(例如,将第 5 行移动到第 15 行)
- 啊啊啊啊
- cccccccc
- dddddddddd
- eeeeeeee
- 万维网
- 呸呸呸呸
PS OS X系统,不知道有没有关系...