LoginSignup
1
0

More than 1 year has passed since last update.

Linux—ASCIIの並び順で遊んでみよう ( ls コマンドと一緒に )

Last updated at Posted at 2018-08-12

参考

スクリプトの例

色んな名前のファイルを作って ls の結果を見てみる。

mkdir -p ./names

touch './names/"'
touch './names/#'
touch './names/+'

touch './names/...'
touch './names/....'

touch './names/0'
touch './names/1'
touch './names/2'

touch './names/ALICE'
touch './names/bob'
touch './names/CAROL'
touch './names/david'
touch './names/Eric'
touch './names/fred'

cd ./names/
ls -la -1
cd ../

rm -rf ./names

出力例

カレントディレクトリ . や一個の上のディレクトリ .. よりも、先に表示されているものがあることに気づく。

普段僕らが見ている点々たちは、別に何も特別扱いされてるわけじゃなくて、単に ASCII の並び順で先頭に表示されていただけなんだな。

"
#
+
.
..
...
....
0
1
2
ALICE
CAROL
Eric
bob
david
fred

環境

  • GNU bash, version 4.4.23(1)-release (x86_64-apple-darwin17.5.0)
  • Mac OS X High sierra

参考

Gist

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

1
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
1
0