æ©ébash4.0ã®æ°æ©è½ãã¬ãã¥ã¼ãã¦ã¿ã
bash4ãåºããbash4ã¨zshã®éããæ°ã«ãªã£ã¦ããèªåã¨ãã¦ã¯ãã¦ããã£ã¦ãããããã³ã³ãã¤ã«ï¼å®é¨ãã¦ã¿ãã
åå¾ãã³ã³ãã¤ã«ãã¤ã³ã¹ãã¼ã«
ç°¡åã ã£ãã
wget http://ftp.gnu.org/gnu/bash/bash-4.0.tar.gz tar xzf bash-4.0.tar.gz cd bash-4.0 ./configure make sudo make install
ãµããã£ã¬ã¯ããªãå帰çã«ãã¡ã¤ã«æ¤ç´¢ããglobstar
shopt -s globstarããã¨å帰çã«ããããã*ã§ãã ** ã使ããããã«ãªãã
$ mkdir -p a/b a/c/d a/e/f a/e/g ; touch a/A a/b/B a/c/C a/c/d/D a/e/E a/e/f/F a/e/g/G $ for i in a/** ; do echo $i ; done a/A a/b a/c a/e $ shopt -s globstar $ for i in a/** ; do echo $i ; done a/ a/A a/b a/b/B a/c a/c/C a/c/d a/c/d/D a/e a/e/E a/e/f a/e/f/F a/e/g a/e/g/G
testã³ãã³ãã¨çµã¿åãããã¨findãä¸è¦ã«ãªãã¨ããããã?
$ for i in a/** ; do if [ -f $i ]; then echo $i ;fi ; done a/A a/b/B a/c/C a/c/d/D a/e/E a/e/f/F a/e/g/G
fi;doneãåé·ã«è¦ãããfindã-execã§ã¯ \{} \; ãå¿ è¦ã ãããªã
è¿½è¨ 2009/02/25 23:50:26:
以ä¸ã®2ã¤ã®è¡¨è¨ã§ãOK
$ for i in a/** ; do [ -f $i ] && echo $i; done $ for i in a/** ; { [ -f $i ] && echo $i; }
ãã£ã¬ã¯ããªåãå ¥åããã ãã§ã«ã¬ã³ããã£ã¬ã¯ããªãå¤æ´ã§ããautocd
ãããã»ããããã¨ãã£ã¬ã¯ããªåã§cdã§ããããã«ãªãã
$ a bash: a: command not found $ shopt -s autocd $ a cd a
å ¥åè£å®æã«ãã£ã¬ã¯ããªåã®ã¹ãã«ãã¹ãä¿®æ£ããdirspell
è£å®æã«ã¹ãã«ãã¹ãä¿®æ£ããã¨ããããã¾ã使ããªãã
$ mkdir abcde $ shopt -s dirspell $ cd abf
ããã§è£å®ãã¦ãããã¨æã£ããã ãã©ãªã
$ cd /usr/locl/bin<tab>
ããã¯ãã¡ãã¨ä¿®æ£ãããã ãã©ãªãã
$ cd /usr/local/bin/
caseã®ãã©ã¼ã«ã¹ã«ã¼ãå®ç¾ãã &; ;;&
ã¾ãã使ã£ã¦ã¿ãã°ãããã caseä¸ã§ ;; -> ;&ã«ããã¨ãã©ã¼ã«ã¹ã«ã¼ãå®ç¾ã§ããã
$ case a in a) echo a;; b) echo b;; esac a $ case a in a) echo a;& b) echo b;; esac a b $ case b in a) echo a;& b) echo b;; esac b $ case a in a) echo 1;;& a) echo 2;; a)echo 3 ;; esac 1 2 $ case a in a) echo 1;;& b) echo 2;; a)echo 3 ;; esac 1 3 $ case a in a) echo 1;& b) echo 2;; a)echo 3 ;; esac 1 2
ã¾ããæ» å¤ã«ä½¿ããªãã
æ¨æºã¨ã©ã¼ãæ¨æºåºåã«ãã¼ã¸ããªããã¢ãã³ããã &>>
ã¾ãä»ã¾ã§ã ã¨
$ echo "1">a;ruby -e 'STDOUT.puts("stdout");STDERR.puts("stderr")' >> a 2>&1 $ cat a 1 stderr stdout
ãããããªãã¨æ¨æºåºåããã¼ã¸ãã¤ã¤ã¢ãã³ãåºæ¥ãªãã£ãã®ã
$ rm a; echo "1">a;ruby -e 'STDOUT.puts("stdout");STDERR.puts("stderr")' &>> a $ cat a 1 stderr stdout
ããã§åºæ¥ãããã«ãªã£ãã¨ãã¢ãã³ããããªãã¨ãã«ã¯ &> ã使ãã¦ãããã¾ãåé¡ãªãã ãªã
ææ³
å è¡äºæ¸¬è£å®ãã®ããã°å¤§ä½zshã«è¿ã¥ããã®ã§ã¯ãªããã¨ã
ã¾ãããã¨ä½ç¹ããããã©æ°ã«ããªããå æ¥æ¡å¼µããfcã³ãã³ãããããï½ > bashのfcコマンドを整形後にエディタで編集する - 計算機と戯れる日々
å±¥æ´ã®ãã¼ã¸çã¯ãbashをzshに負けないぐらい高機能化するためのtips - 計算機と戯れる日々ããããã°ä»æã®ãã·ã³ãã¯ã¼ãªãå ¨ãåé¡ãªãã
ã¯ããubuntuã«å°å ¥ãããªãããªã