ç¥ããªãã£ãyesã³ãã³ãã®çã®å
yesã³ãã³ãã¨ã¯ï¼
'YES' - å¦ç²¾ãã¿ãã¦ãã¾ãã¸ã§ã³ã¢ã³ãã¼ã½ã³ã®ããã°ã¬ãã·ããã³ãã®ãã¨ã§ã¯ããã¾ãããUNIX/Linux ã® yes ã³ãã³ããå°ãã ãèªã£ã¦ã¿ããã¨æãã¾ãã
yesã³ãã³ãã£ã¦ãªãã§ããï¼ã¨ãã人ã¯ã¾ãUNIX/Linuxã®ã¿ã¼ããã«ã§'yes'ã¨å ¥åãã¦ã¿ã¾ãããã
$ yes y y y^C
y ãã²ãããç¶ãã¾ããå¼æ°ã«æååã渡ãã°ãã®æååãã²ãããåãåºãã¾ãã
$ yes "Cirque du Soleil" Cirque du Soleil Cirque du Soleil Cirque du Soleil Cirque du Soleil^C
ããæå³ããã®ï¼ã¨æããããªãã¾ããã§ã¯ä½ã«ä½¿ããã®ã§ãããï¼ ããã¿ã¼ããã«ã§å¯¾è©±çã«è¡ãã¨ãã« ãªã㨠ãã® y ãå ¥åãã¦ãããã®ã§ãã
yesã®ä¾
ã¾ããã¹ããã¡ã¤ã«ä½æ
$ for i in foo hoge bar huga; do touch ${i}.txt; done $ ls *.txt bar.txt foo.txt hoge.txt huga.txt
rm -i ãªã®ã§å¯¾è©±çã«ãªãã¾ãã
$ rm -i *.txt rm: é常ã®ç©ºãã¡ã¤ã« `bar.txt'ãåé¤ãã¾ãã? ^C
yes ã使ã㨠'y'ã§å ¨é¨æ¶ãã¦ãããï¼ï¼
$ yes | rm -i *.txt rm: é常ã®ç©ºãã¡ã¤ã« `bar.txt'ãåé¤ãã¾ãã? rm: é常ã®ç©ºãã¡ã¤ã« `foo.txt'ãåé¤ãã¾ãã? rm: é常ã®ç©ºãã¡ã¤ã« `hoge.txt'ãåé¤ãã¾ãã? rm: é常ã®ç©ºãã¡ã¤ã« `huga.txt'ãåé¤ãã¾ãã?
ãªãã¦ç·ãããã³ãã³ãã ããï¼ ã\rm -f ã§ããããããããããã£ããã® "prompt before every removal" ã®æå³ããªããã¨è¨ããããã§ããã©æ°ã«ããªãã§ãã ãããç§ã¯ä»¥ä¸ã¿ãããªä½¿ãæ¹ãã¦ãã¾ãã
ã¦ã¼ã¶ã®ä¸æ¬ä½æã³ãã³ã
ã©ã³ãã ã«çæãããã¹ã¯ã¼ãã passwdã³ãã³ãã§å¯¾è©±çã«å¤æ´ããã¨ãããã yesã³ãã³ãã§èªåçã«å ¥åãã¾ãã
#!/bin/bash gen_password() { dd if=/dev/urandom count=2000 bs=1 2>/dev/null|\ LC_ALL=C tr -d -c '[:alnum:]' | cut -b -20 } for u in cartman stan kenny kyle do id $u > /dev/null 2>&1; stat=$? [ $stat -eq 0 ] && continue useradd -s /bin/bash -d /home/$u $u > /dev/null password=`gen_password` yes $password | passwd $u > /dev/null 2>&1 echo "$password - $u" done
ãããªæãã§ã¦ã¼ã¶ãä¸æ¬ã§ä½æã
$ sudo bash gen_users.sh PoWjCBIea5IYCRVgVGIc - cartman DfLxpH9WuLfesCY9VD3V - stan U2Lsz82TuZK57vo7tcOL - kenny FjDOSQPavo2YAuENztd9 - kyle
ããã¼ æ¬å½ã«yesã³ãã³ãã¯ä¾¿å©ã§ããã