Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?


More than 1 year has passed since last update.


for f in `ls`; do cp $f ${f/<1>/<2>}; done


$ ls
hoge2017-1hoge.pdf  hoge2017-3hoge.pdf  hoge2017-5hoge.pdf
hoge2017-2hoge.pdf  hoge2017-4hoge.pdf  hoge2017hoge.pdf

# hogeのつく、下から5件のみコピーして、2017の部分のみを2018に変更
$ for f in `ls hoge* | tail -n5`; do cp $f ${f/2017/2018}; done
$ ls
hoge2017-1hoge.pdf  hoge2017-4hoge.pdf  hoge2018-2hoge.pdf  hoge2018-5hoge.pdf
hoge2017-2hoge.pdf  hoge2017-5hoge.pdf  hoge2018-3hoge.pdf  hoge2018hoge.pdf
hoge2017-3hoge.pdf  hoge2017hoge.pdf    hoge2018-4hoge.pdf
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away