开发者

match multiple files by the number in filename

开发者 https://www.devze.com 2023-02-17 01:52 出处:网络
I have many files abc_001开发者_开发百科.txt, abc_002.txt, ..., abc_999.txt in a directory. How can i select abc_001.txt ... abc_100.txt? i want to copy or tar them.In Bash you can make a list of all

I have many files abc_001开发者_开发百科.txt, abc_002.txt, ..., abc_999.txt in a directory. How can i select abc_001.txt ... abc_100.txt? i want to copy or tar them.


In Bash you can make a list of all numbers in a range: abc_{001..100}.txt


Try:

cp abc_0[0-9][0-9].txt abc_100.txt destination/

... or:

tar cvf archive.tar abc_0[0-9][0-9].txt abc_100.txt


You just need abc_0??.txt and abc_100.txt :)

0

精彩评论

暂无评论...
验证码 换一张
取 消