LoginSignup
0
0

More than 3 years have passed since last update.

[shell] ファイル名が7文字のものだけ、名前を変更する

Posted at

達成したいこと

カレントディレクトリ中のファイル一覧を取得。
ファイル名が7文字のものだけ、頭に「0」をつけリネームする

コード

for file in `ls` 
do 
  count=`echo $file | wc -c`

  if [ $count -eq 7 ]; then
   rename 's/^/0/' $file
  fi
done
0
0
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
0