0
0

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.

特定の文字数のディレクトリ名の先頭に0をつける

Last updated at Posted at 2019-04-16
  • 5桁と6桁の数字の名前が混在したディレクトリ群から、5桁のものだけ先頭に0をつける必要があったので自分用にメモ

#ディレクトリ名の先頭に0をつける

$ ls -F
12345/ 23456/ 345678/ 456789/

-Fオプションでディレクトリ名末尾にスラッシュがつく

$ for dirname in `ls -F | grep -x ...../`
> do
> mv $dirname 0$dirname
> done

grepの-xオプションで、部分一致ではなく完全一致のときのみ抽出するようにする

$ ls
012345/ 023456/ 345678/ 456789/
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?