More Related Content
Similar to bash(set)コマンドのオプション3選
Similar to bash(set)コマンドのオプション3選 (6)
More from Yuuki Namikawa (15)
bash(set)コマンドのオプション3選
- 2. 自己紹介
• 並河 祐貴 (a.k.a. id:rx7)
• (株)サイバーエージェント所属
• エンジニア(Ops)
• Blog: http://d.hatena.ne.jp/rx7/
• Twitter: @namikawa
• 著書・寄稿多数
- 5. 私の結果・・・
$ history | awk '{print $2}' | sort | uniq -c | sort -nr
390 ll
322 cd
217 vim
・・・省略・・・
1 e
1 xit
1 ihai
1 ヴぁgらんt
1 :q
- 7. bashのシェルオプション
• man bashで勉強
• SHELLOPTS変数で確認できる
• setコマンドとかでも指定できる
$ echo $SHELLOPTS
braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
- 10. errexit
$ cat test.sh
#!/bin/bash
mkdir /tmp/hoge/fuga
touch /tmp/hoge/fuga/test.txt
$ bash test.sh
mkdir: cannot create directory '/tmp/hoge/fuga': No such file or directory
touch: cannot touch '/tmp/hoge/fuga/test.txt': No such file or directory
$ bash -e test.sh
mkdir: cannot create directory '/tmp/hoge/fuga': No such file or directory
- 12. xtrace
$ cat test.sh
#!/bin/bash
mkdir /tmp/hoge/
touch /tmp/hoge/test{1,2}.txt
ls -l /tmp/hoge/*
$ bash test.sh
-rw-r--r-- 1 nami nami 0 5月 28 23:55 /tmp/hoge/test1.txt
-rw-r--r-- 1 nami nami 0 5月 28 23:55 /tmp/hoge/test2.txt
$ bash -x test.sh
+ mkdir /tmp/hoge/
+ touch /tmp/hoge/test1.txt /tmp/hoge/test2.txt
+ ls -l /tmp/hoge/test1.txt /tmp/hoge/test2.txt
-rw-r--r-- 1 nami nami 0 5月 28 23:56 /tmp/hoge/test1.txt
-rw-r--r-- 1 nami nami 0 5月 28 23:56 /tmp/hoge/test2.txt
- 14. norc
$ cat .bashrc
alias ll='ls -l‘
$ bash
bash-4.3$ ll
total 32
drwx------ 3 nami nami 102 5 26 11:08 Applications
drwxr-xr-x+ 4 nami nami 136 5 28 23:06 Desktop
・・・省略・・・
$ bash --norc
bash-4.3$ ll
bash: ll: コマンドが⾒つかりません