Created
October 5, 2012 17:23
-
-
Save kawaz/3841145 to your computer and use it in GitHub Desktop.
カレントディレクトリからランダムに一つのファイル名を出力するbashスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| files=(.[^.]* *) | |
| echo ${files[$RANDOM%${#files[@]}]} |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
files=(*)って空白文字含むファイルがあったらバラけちゃうのかな?と不安だったんだが、ちゃんとバラけずファイルごとに配列に入ってくれて感心した。