0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

シェルスクリプトで連番ファイルを消去&生成

Posted at

連番をつくる

seqというコマンドを使えばよいが、桁数を指定したいとき、-fオプションを用いる。
「seq -f %0桁数 最初の数 最後の数」
という風にかく。0を書くのを忘れずに、、、

# !/bin/bash

for NUMPATH in `seq -f %05g 1 96`
do
 echo "flow_z${NUMPATH}_0000950000"
done

実行結果はこの通り、

rm flow_z00081_0000010000
   (省略)
rm flow_z00095_0000950000
rm flow_z00096_0000950000

利用例

連番ファイルを消去したいのに、ワイルドカードだと制限数をオーバーする、うまく記述できないし、正規表現を使うのもなんだかなーというとき、上のコードで対応できる。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?