The slides I used for my presentations at YAPC::Asia 2010 are now available from the links below. Thank you to those who came, and JPA and the volunteer stuff for running the event. I hope you enjoyed (will enjoy) my slides!
ããã¯ç´ æµããããµã¤ãã Command-line-fuã§ã¯Linuxãªããã®ã³ãã³ãã©ã¤ã³ã§ä½¿ããã¯ã³ã©ã¤ãã¼ï¼ä¸è¡ããã°ã©ã ï¼ãæ稿ã»å ±æã§ããã èªåããã使ãã¯ã³ã©ã¤ãã¼ãä¿åãã¦ããã¦ä½¿ããè¯ããä»ã®é人ã®æãçããè¯ããã®ç´ æ´ããããµã¼ãã¹ã§ããã ã¡ãã£ã¨ã®ããã¦ã¿ãã ãã§ããã¸ã¼ãä¸è¡ã§ããã¾ã§åºæ¥ããã ã»ã»ã»ãã¨ããå°æããã£ã¦ããªãåå¼·ã«ãªãã ã¾ãæ´æ°æ å ±ã¯RSSãTwitterã§ãé ä¿¡ãã¦ããã®ã§æ¥ã åå¼·ï¼ã¨ãã人ã«ã¯ä¾¿å©ã ãããããããå°æãã¦ãã¦ã®å ±æãµã¤ãã¯ããã§ããã
æ´èµ°ãã¦ã©ãã©ãã¡ã¢ãªãé£ãã¹ã¯ãªããã OSå ¨ä½ã®ã¡ã¢ãªä½¿ç¨é(CentOS5 ... ã«ã¼ãã«ã¯2.6ç³»ã«ãªã)ã®åä½ã«ã©ããªå½±é¿ãä¸ããã®ããã£ã¦ã®ãè¦ãããã«ä»¥ä¸ã®ãããªãã¹ãããã¦ã¿ã¾ãããä»çµã¿ã¯ã ãããç解ãã¦ããã©ãç´°ããæ°å¤ã追ã£ããã¨ã¯ãªãã£ãã®ã§ãã£ã¦ã¿ã¾ããã sshã§ãã°ã¤ã³ãã¦ãtopãç«ã¡ä¸ãããããã»ã¹ãè¦å¼µãç¨æããã¦ãã å¥ã®sshããã¡ããã¦ã Perlã¯ã³ã©ã¤ãã¼ã§ä»¥ä¸ã®ãããªããã»ã¹ãèµ°ããã(ãã®ããã»ã¹ãtopã§è¦å¼µã) # 1ç§ãã¨ã«5MBåä½ã§ã¡ã¢ãªãé£ãããã»ã¹ # æ°å¤ã¯ã好ã¿ã§ perl -e "while(1){ sleep 1; push @h , 1 x 1024 x 1024 x 5 } " ã¡ãªã¿ã«topã§è¦å¼µãã¨ã㯠ã¡ã¢ãªä½¿ç¨éã§ã½ã¼ããããããã«ã㦠topèµ·åä¸ã« shift + o ãæ¼ã㦠n ãæ¼ã㨠å®ã¡ã¢ãª
YAPC::Asia 㧠Perl UNIX ãããã¯ã¼ã¯ããã°ã©ãã³ã°ã«ã¤ãã¦ã®çºè¡¨ããã¦ãã¾ãããUNIX ãããã¯ã¼ã¯ããã°ã©ãã³ã°ã®åºç¤ã®æ¦è«ãI/Oå¤éåã®è©±ãPerl ã®ã¢ãã³ãªãããã¯ã¼ã¯ã©ã¤ãã©ãªã®è©±ã§ããè³æã以ä¸ã«ç½®ãã¦ããã¾ãã http://bloghackers.net/~naoya/ppt/070404Perl_and_UNIX_Network_Programming.ppt (ppt, 122k) ãªããä¼å ´ã§ã¯å£é ã§è§¦ãã¾ããããè³æä¸ã®ã½ã¼ã¹ã¯ç°¡åã®ããã¨ã©ã¼å¦çãé£ã°ãã¦ãã¾ããã¾ããéä¸ã§åºã¦ããå³ã¯ä¾ãã° vfs ã®ãã¼ã¸ãã£ãã·ã¥ãã¯ããã£ã¦ãã£ããã¨ãããç°¡åã®ããçç¥äºé ãããç¹ã«ã注æãã ããã ãããããã©ã³ãã Consolas ãªã®ã§ Consolas ãå ¥ã£ã¦ãªãç°å¢ã ã¨å¤ã«ãªããããã
ã¦ãã¦ã©ã Unoh Labs: ã³ãã³ãã©ã¤ã³ã§ä½æ¥ããä¸ã§ç¥ã£ã¦ããã¨ãããã¯ããã¯% find . -name '*~' -exec rm {} \; 404 Blog Not Found:åæã«æ·»å - find(1)% find . -type f -name '*~' | xargs rm % find . -type f -name '*~' | perl -nle unlink ããããªã% find . -type f -name '*~' | sed 's/^/rm /'ã§ç¢ºèªããOK ãªã% find . -type f -name '*~' | sed 's/^/rm /' | shã§æ¶ãã¾ãã ãã¾ã©ã fork/exec rm ã®ãªã¼ãã¼ããããã©ãã»ã©ã®ãã®ãã xargs ã使ãã¨ããrm ã 1åã ãå®è¡ãããã¨ãã¨ãARG_MAX ãè¶ ããã¨ãã« rm
æ¸ããæ¸ããæ¸ããã¨æã£ã¦ãããå ã«æ¸ããã¦ãã¾ã£ãã 404 Not Found ãã®è¡ãå ´ã®ç¡ãææ ãã©ãã«ããã¯ã®ä¸ããæé¤ããªããã°ãªããªãã ããèããã¨ãã«ç¬ãè¨ã®ããã«ãã®ããã°ãã«è¨è¿°ããã°è¯ããããªããã¨ãã çµè«ã«ãã©ãçããã®ã¯ãã¯ãå¿ ç¶ã¨ãè¨ããã find | xargs ã«ããæ¢ç´¢ã ãããããç°¡åãªãã®ã§ããã° å®ã¯ grep ã³ãã³ãã ãã§ãã¾ãããã GNU grepãBSD 系㮠grep ã³ãã³ãã§ã¯ includeãexclude ãªãã·ã§ã³ã§å帰æ¤ç´¢æã«æ¤ç´¢å¯¾è±¡ã¨ãããã¡ã¤ã«ãçµãè¾¼ãäºãåºæ¥ãã®ã ã --include=pattern --exclude=pattern ãã¨ãã°ãã«ã¬ã³ããã£ã¬ã¯ããªä»¥ä¸ã® *.rb ãã test ã¨ããæååã å«ããã¡ã¤ã«ãæ¢ç´¢ãããå ´åã¯æ¬¡ã®ããã«ããã°è¯ãã fgrep -r --include='*.r
çï¼psã®STATããDãã®ãããã ãã alias iops='ps auxwwww|awk "\$8 ~ /(D|STAT)/{print}"' ã¨ãã§ããã
shell 㨠SIGHUP - odz buffer é¢é£: ä¸åº¦ tty ããèµ·åããããã»ã¹ (csh/ksh ç) - ã«ã½ããç 究æ ãªãã»ã©ãzshã§ã¯ããã©ã«ãã 㨠çµäºæã«SIGHUPãéä¿¡ããããããã æå ã®bash2.0ã§è©¦ãã¦ã¿ããçµäºæã«SIGHUPãéä¿¡ãããªãã£ãã zshã§çµäºæã«è¦åãåºããªãããã«ããã«ã¯ã setopt nocheckjobs ã¨ããã°ããããã ã ãã¨ãzshã«ã¯ãããªãdisownã®ç¶æ (job tableã«å ãããªãç¶æ )㧠ããã¯ã°ã©ã¦ã³ãå®è¡ãã &! ã¨ããè¨æ³ãããã SIGHUPéãããªãã % perl nohup.pl &! % exit % pgrep -fl nohup.pl 524 perl nohup.pl -- ä½è«ã ããzshã§ã¯setoptã«æå®ãããªãã·ã§ã³å㫠好ããªã ãã¢ã³ãã¼ãã¼ãã¤ããäºãåºæ¥
ref:ä¸åº¦ tty ããèµ·åããããã»ã¹ (csh/ksh ç) - ã«ã½ããç 究æ id:lurker ããã®ããã¯ãã¼ã¯ã³ã¡ã³ããã disownã¯SIGHUPç¡è¦ããããã«ãã¾ããbgã¨ã¯ã¡ãã£ã¨éããã®ã ã¨æãã¾ãã/gdb使ãã°å ¥åºåã¯å·®ãæ¿ããããã ã ãããã¨ãæãã¤ã¤(gdbã使ã£ã端æ«å·®ãæ¿ãã¯æ°ã«ãªããã©ã¨ããããã¹ã«ã¼)ãzsh 㨠tcsh ã§è©¦ãã zsh ã§ã % cat nohup.pl #!/usr/bin/env perl use strict; use warnings; $SIG{HUP} = sub { print "recieved SIGHUP\n"; exit; }; while (1) { sleep 10; } % ./nohup.pl & % exit zsh: you have running jobs. % exit recieve
shell ã®ã¡ãã£ã¨ãããã¯ãã㯠- odz buffer odzããã®ã¨ããã§åèªã®åºç¾é »åº¦ã調ã¹ãããã®ã¯ã³ã©ã¤ãã¼ãç´¹ä»ããã¦ããã åèªæ½åºã«ã¤ãã¦ã¯ããã¤ãããæ¹ãããã®ã§ç´¹ä»ããã ç¹ã« egrep -o ã¯é常ã«å®ç¨çã ãã¡ããããã®è©±ã¯ãªã³ã¯å ã«ããã¦ä¸»é¡ã§ã¯ãªãã 俺ã®ãã ã®èªå·±æºè¶³ã tr -cs ã§åèªæ½åº $ tr -cs 'a-zA-Z' '\n' < ./.zshrc ä¸è¨ã³ãã³ãã§ãa-zA-Zã®ã¿ã§æ§æãããæååãæ½åºã§ããã -c ãªãã·ã§ã³ã§ã'a-zA-Z' ã®è£éå(以å¤)ã '\n' ã«å¤æãã -s ãªãã·ã§ã³ã§ãæå¾ã®å¼æ°ã§æå®ãããè¦ç´ ã®éè¤ãé¤å»ãã¦ãããããªãã¡ '\n' ã®é£ç¶ãé¤å»ãã¦ããã grep -o ã§åèªæ½åº grepã«ã¯ã( -oã--only-matching ) ãªãã·ã§ã³ã¨ããã®ãããã ããã¯ãæå®ãããæ£
2007å¹´01æ18æ¥08:00 ã«ãã´ãªLightweight Languages perl - pargs = xargsã¢ãã GNUãããªããã ä½ã£ã¦ãã¾ã xargs. æè¡ã¡ã¢å¸³ - xargsã³ãã³ãã使ã£ã¦æå®ããã³ãã³ãã並åå®è¡ããã ãã¾ãç¥ããã¦ããªãããGNUã®xargsã³ãã³ãã«ã¯ã ããã»ã¹ã®æ大æ°ãè¨å®ã§ãããªãã·ã§ã³ã¨ããã®ãç¨æããã¦ããã ã³ã¬ã使ã£ã¦ãããã»ã¹ã並åå®è¡ããã¦ã¿ããã OS Xã®xargs(1)ã¯gnuçãããªããã ããã ã¨ããããã§perlã§å³èã§ä½ã£ãã®ããã¡ãã pargs #!/usr/local/bin/perl use strict; use warnings; use Getopt::Std; use POSIX ":sys_wait_h"; our $PPID = $$; our %Opt; getopts "P:
ãããã°ããã¹ããè¡ã£ã¦ããã¨ãããã°ã©ã ãç¡éã«ã¼ãã«å ¥ãè¾¼ãã§è¿ã£ã¦ããªããããªç¶æ³ãçºçãããã¨ãããã¾ãã ãã®ãã°ãåç¾ã®é£ãããã®ã§ããã°ãgdbã使ã£ã¦èµ·åãã¨ãã°è¯ãã£ãããããã¨ãããããªæ°åã«ãªãæãããã¾ãã ããããgdbã«ã¯æ¢ã«èµ·åãã¦ããããã°ã©ã ã®å¶å¾¡ã横ãã奪ãåã£ã¦ãããã°ããã¨ãããããããæ©è½ãããã¾ãã ããã§ã¯ãæ¢ã«èµ·åãã¦ããããã°ã©ã ãgdbã§ãããæ¹æ³ã説æãããã¨æãã¾ãã å®éã«ãããã°ãããæ¹æ³ã説æããã¨ããããã¯ãgdbã§åãã¦ããããã»ã¹ã«ã¢ã¿ããããä¾ã説æãã¾ãã ãã®å¾ã®ãããã°ã«é¢ãã¦ã¯ããã¤ãã®gdbã®ä½¿ãæ¹ããã¦ããã ããã°å¤§ä¸å¤«ã§ãã ã¨ããããã¢ã¿ãããã¦ã¿ã æ¢ã«èµ·åãã¦ããããã»ã¹ãgdbã解æããã®ã¯é常ã«ç°¡åã§ãã åã«gdbã§ããã»ã¹ã«ã¢ã¿ããããã ãã§ãã gdbã§ããã»ã¹ã«ã¢ã¿ããããæ¹æ³ã¯2ã¤ããã¾
ãã¾ãç¥ããã¦ããªãããGNUã®xargsã³ãã³ãã«ã¯ã ããã»ã¹ã®æ大æ°ãè¨å®ã§ãããªãã·ã§ã³ã¨ããã®ãç¨æããã¦ããã ã³ã¬ã使ã£ã¦ãããã»ã¹ã並åå®è¡ããã¦ã¿ããã xargs --max-procs=MAX-PROCS -P MAX-PROCS command MAX-PROCSã«æ°åãæå®ããã¨ã æ大ã§ããã®æ°ã ã command ããã»ã¹ãçæããã ããã©ã«ãã¯ã1ããã»ã¹ã ãã«ãªã£ã¦ããã ããã¤ãä¾ã交ãã¦èª¬æããã ãµã³ãã«ã¨ãã¦ã以ä¸ã®ããã«URLãè¡ãã¨ã«è¨è¿°ããããã¡ã¤ã«ãå ã« curlãxargsã§ä¸¦åå®è¡ãã¦ãHTMLãã¼ã¿ãåå¾ãã¦ã¿ããã $ cat ./url_list.txt http://www.google.co.jp/ http://www.yahoo.co.jp/ http://b.hatena.ne.jp/ ã¾ããæ®éã«xargsã使ã£ã¦c
zsh ã«ã¯ãzargsã³ãã³ã(çµã¿è¾¼ã¿é¢æ°) ã¨ããã®ãç¨æããã¦ããã ããã¯ãæ¡å¼µã°ããç¨ã® xargs ã³ãã³ãã¨è¨ã£ã¦ãè¯ãã ããã ããã¥ã¢ã«ãè¦ãã¨ãxargs ã³ãã³ãã¨ãªãã·ã§ã³ã¯ãå®å ¨ã«äºæãã¦ãããããã autoload zargs ã¨ããäºã§å©ç¨å¯è½ã ã 使ãæ¹ã ããxargs ã¨ããã¨ãæ¨æºå ¥åããèªã¿è¾¼ãã è¦ç´ ãè¡ã«å¯¾ã㦠ç¹å®ã®ã³ãã³ããå®è¡ããã¨ãããã®ã ã zargs ã®å ´åã¯ãå¼æ°ã«æå®ãã æ¡å¼µã°ãã ã«å¯¾ãã¦ãããã®å¦çãè¡ãã % zargs OPTIONS -- æ¡å¼µã°ãã -- å®è¡ãããã³ãã³ã ãã¨ãã°ãxargs ã§ä¸çªå©ç¨ãããã¨æããã ãã¡ã¤ã«æ°ã ARG_MAX ãè¶ãã¦ãã¾ã£ã¦ãããã£ã¬ã¯ããªå ã®ãã¡ã¤ã«ã ã¾ã¨ãã¦åé¤ãããå ´åãªã©ã¯ã次ã®ãããªã³ãã³ããå ¥åããã°è¯ãã % zargs -- ./* -- rm ããã ã
2007å¹´01æ14æ¥05:30 ã«ãã´ãªLightweight Languagesä¸æ¥ä¸è¡éé perl - Yet Another 10ã®UNIXå°æ Geekãªãºã¼ãï¼10ã®UNIXå°æã«perlãå ããã¨ããã«å¹¸ãã«ãªããã¨ããã話ã 1.ãã£ã¬ã¯ããªã®ä½æ ä»æ-pããµãã¼ããã¦ããªãmkdir(1)ã¯ãªãã¨æãã¾ããããªãå ´å㯠perl -MFile::Path -e 'mkpath $_ for @ARGV' path/to/dir more/path/to/dir ... ã§ä»£ç¨ãåºæ¥ã¾ãã alias mkpath perl -MFile::Path -e \'mkpath \$_ for @ARGV\' ã¨.bashrcã.cshrcã¨ãã¦ããã°ã mkpath path/to/dir more/path/to/dir ... ã¨åºæ¥ã¾ãã 2. tarã®è§£åå ãæå®
åã¨ã³ããªWeb2.0ã¨C10Kã«é¢ããæ°ã ã®èª¤è§£ã«é¢ãã¦ã¯ããããããã³ããããã ãã(ãããã¨ããããã¾ã). åç¡ã ã誤èªããä¸ã«ããããã«å¾®å¦ãªè§£èª¬ãããããæ¥ãããããã¾ããã ããããã§å¾®å¦ãªè§£èª¬ãªã®ã¯ã¾ããããªã®ã§å¦å®ããªãã,誤èªã¨ã¯ãªãã®ãã¨ã ãã? ããããã¨ãã¯ä»ã¯ããã®ãã¹ã«ã¼åããçºæ®ããã®ã大人ã®ã¤ã³ã¿ã¼ããããã¨æã£ãããã©, ç§ã®Blogãæ±ãå 容ã¯é常ã«çã,ããã«ããã«å¯¾ãã¦çªã£è¾¼ããã¨æã人㮠æè¦ã¯ãªã«ãããã®çå®ãå«ã¾ããã¯ãã¨èãã¦ããã¨ãã,ä¸è¨ã¨ã³ããªããã£ã. å è¨äºã®äººã¯ä¸ã§ãã 3ï¼6 ããããæ¸ãã¦ãã¦ï¼id:yamaz ãã㯠3 ãããªã 4 ã¨ã常èã ãï¼ã¨åã¿ã¤ãã¦ããããã«èªãã¾ããã. ãªãã»ã©,ç§ã®åã¨ã³ããªã¯@ITã®å è¨äºã«å¯¾ãã¦åã¿ã¤ãã¦ããããã« èªããããã (è¨ããã¦ã¿ãã°ãããã«ããèªãã). å®éã®æã¯å è¨
IBMã®ãµã¤ãã§ãLearn 10 good UNIX usage habitsãã¨ããè¨äºãçºè¡¨ããã¦ãã¾ããã é¢ç½ãã£ãã®ã§è¦ç´ãã¦ã¿ã¾ããã å¤ãªé¨åãããããç¥ããªãã®ã§è©³ç´°ã¯åæãã覧ä¸ããã åæã¨ã¯ä¸é¨ç°ãªãã¾ãã æ¬ãã¼ã¸ã¹ãã¼ã¹ãªã©ã®é¢ä¿ã§ã³ãã³ãå¼æ°ãªã©ãçãçç¥ãã¦ãã¾ãã åæã®ãµã³ãã«ã³ãã³ããééã£ã¦ãããããã®ã§ãä¿®æ£ãã¦ããé¨åãããã¾ãã åæãä¿®æ£ãã¦ããã®ã¯ãtar.gzãzãªãã·ã§ã³ã使ããªãã§xfvãããã¨ãã¦ããã¨ããã¨ãxargsã«lsã§ã¯ãªãls -lã渡ãã¦ããé¨åã§ãã ãã¨ã説ææãçããã¦ãã¾ã£ã¦ãã¾ãã 1. ãã£ã¬ã¯ããªã®ä½æ è¯ã使ãã³ãã³ãã®ä¸ã¤ã§ããmkdirã§ãããé¢åèã使ãæ¹ããã¦ãã¾ãããï¼ æªãä¾ ~/ $ mkdir a ~/ $ cd a ~/a $ mkdir b ~/a $ cd b ~/a/b/ $ m
ã©ã³ãã³ã°
ã¡ã³ããã³ã¹
ãç¥ãã
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}