Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?
ã·ã§ã«ã§ãã¼ã¿å å·¥ããã¨ãSEDããã使ãã¾ããããã®å©ç¨ä¾ã¨è¦ãæ¸ãã§ããåèã«ãªãã° sedã³ãã³ãã¯Linux/Unix/BSD/OSXã«æ¨æºã§å ¥ã£ã¦ããã®ã§ãMacã®äººãªãè¦ãã¦ããã¨æããã(Linuxã¨ã¯å°ãéãã®ã§ããã¯èª¿ã¹ã¦ã?) å½æ¹ã®å©ç¨ç°å¢ãRedhatç³»Linuxã¡ã¤ã³ã§ãã®ã§ãå¾®å¦ã«æ¸å¼ãç°ãªããã¨ãããã¾ããã大ä½ã®æ¸å¼ã¯åãã¯ãã§ãã®ã§ãããã¯ãã容赦é¡ãã¾ã (4/15 ã¡ãã£ã¨è¿½å â¦) Windowsã§ãsed使ãããã¨ãã人ãããã®ã§ãã¡ãã£ã¨è¿½è¨ã以ä¸ã®ãµã¤ãããWindowsç¨ã®ãã¤ããªãåå¾ããã°ãWindowsã§ãsedã使ãã¾ããWSLãªã©Linuxç°å¢ã追å ããããªããsedã®ã³ãã³ãã ãã»ãããPowerShellãããã³ããã§ä½¿ããã°ããã ãã¨ãã人ã«ãå§ãã§ãã sed for Windows Site 使ç¨ä¾ãããããä¸ãã¦ã¿ã '#
解説 TIPSãWindows 10ã®Linuxï¼Ubuntuäºæç°å¢ã§bashã使ããã§ã¯ãWindows 10ã®ãã¼ã¸ã§ã³1607ï¼ãã«ã14393ãAnniversary Updateï¼ã«æ°ãã«å°å ¥ããããUbuntuäºæã®å®è¡ç°å¢ãWindows Subsystem for Linuxï¼WSLï¼ãã¨ãbashï¼Bourne Again Shellï¼ãã®ã¤ã³ã¹ãã¼ã«æ¹æ³ã«ã¤ãã¦è§£èª¬ããã ãã®bashç°å¢ãå©ç¨ããã¨ãLinuxï¼Ubuntuåãã®ãããã±ã¼ã¸ãï¼ããã°ã©ã ã®ã½ã¼ã¹ã³ã¼ããããã¯ãã¤ããªãã¡ã¤ã«ãªã©ã1ã¤ã«ã¾ã¨ãããã®ï¼ããã®ã¾ã¾ã¤ã³ã¹ãã¼ã«ãã¦å©ç¨ã§ããããã«ãªãããã ãããã±ã¼ã¸ã®ç®¡çæ¹æ³ï¼è¿½å ãåé¤ãªã©ã®æ¹æ³ï¼ã¯Linuxã®ãã£ã¹ããªãã¥ã¼ã·ã§ã³ãã¨ã«ããããç°ãªã£ã¦ããã®ã§ãå°ãé¢åã§ããã æ¬TIPSã§ã¯ãWindows 10ã®WSLåãã®ããã±ã¼ã¸ç®¡çæ¹æ³
æå¾ã«ãã¡ã¤ã«ã®ã¹ãã¼ã¿ã¹ãå¤æ´ããæéã§ã½ã¼ãã詳細表示ã®ã¨ãã«ã¯ãæå»ã®æ¬ãæå¾ã«ãã¡ã¤ã«ã®ã¹ãã¼ã¿ã¹ãå¤æ´ããæéã«ãªãã
â refs ã»scpã¨sftpã®éãã軽快ãªscpãé«æ©è½ãªsftp,sshã«åãã¦ããã®ã¯ï¼ â ssh,scpã§ãã¡ã¤ã«è»¢é sshã使ç¨ãããã¡ã¤ã«è»¢éscpã³ãã³ãã«ã¤ãã¦ããã¹ãå°ã¨ãã¦awsã®ec2ã«sshã®ãã¼ãã ã空ãã¦ãããã¾ããéµã~/.ssh/DefaultAWSKey.pemã«ããã¦ããã ãã¼ã«ã«ã®hoge.txtãã¡ã¤ã«ã99.199.ââ.ââã®ec2-userã®$HOMEã«è»¢éãããéµã¯hogeKey.pem $ scp -i ~/.ssh/hogeKey.pem hoge.txt [email protected].ââ.ââ: ãã¼ã«ã«ã®hogedirãã£ã¬ã¯ããªã99.199.ââ.ââã®ec2-userã®$HOME/testdir/ã«è»¢éããã $ scp -i ~/.ssh/hogeKey.pem -rp hogedir/ [email protected]
æ¬ãã¼ã¸ã§ã¯ãGoogle Brain Team ã«ãã£ã¦éçºãããããã£ã¼ãã©ã¼ãã³ã° (深層å¦ç¿) ãã¯ããã¨ãããªã¼ãã³ã½ã¼ã¹ã®æ©æ¢°å¦ç¿ã¨ã³ã¸ã³ãTensorFlow ã®ã¤ã³ã¹ãã¼ã«æé ã«ã¤ãã¦ç´¹ä»ãã¾ãã ãªãã2016 å¹´ 7 ææç¹ã§ã¯ãTensorFlow 㯠Linux ããã³ Mac ã®ã¿ã§ã®ã¿å©ç¨å¯è½ã§ãããWindows ã®ãã¤ã㪠(å®è¡ä½) ã¯æªæä¾ã®ãããæ¬æé ã§ã¯ãLinux (Ubuntu 16.04 LTS) ãç¨ãã¾ãã æ¬æé ã¯ãUbuntu 㨠Anaconda ã®ã¤ã³ã¹ãã¼ã«ãå®äºããç¶æ ããéå§ãã¾ããPython ã®ãã¼ã¸ã§ã³ã¯ Python 3.5 (Python3) ãç¨ãã¾ããAnaconda ã®ã¤ã³ã¹ãã¼ã«ãæ¸ãã§ããªãå ´åã¯ãAnaconda ãå©ç¨ãã Python ã®ã¤ã³ã¹ãã¼ã« (Ubuntu Linux) ã®æé ã§ã¤ã³ã¹ãã¼ã«
$ df ãã¡ã¤ã«ã·ã¹ 1K-ãããã¯ ä½¿ç¨ ä½¿ç¨å¯ 使ç¨% ãã¦ã³ãä½ç½® /dev/mapper/centos-root 1361920 1306184 55736 96% / devtmpfs 242508 0 242508 0% /dev tmpfs 251028 0 251028 0% /dev/shm tmpfs 251028 4408 246620 2% /run tmpfs 251028 0 251028 0% /sys/fs/cgroup /dev/sda1 508588 136960 371628 27% /boot ãªã«ãèãããã¨ããããä»®æ³HDDããã2GB追å ãã¦ã«ã¼ããã¹ /ãæ¡å¼µãã¦ã¿ã¾ãã #VirtualBoxã§æ°ããä»®æ³HDDã追å 追å ããVMã®ã¹ãã¬ã¼ã¸è¨å®ç»é¢ãéãã¾ãã ãã³ã³ããã¼ã©ã¼ï¼ SATAããé¸æããã¨ã®å³ã®ã»ãã«HDD追å ãã¿ã³ ãã§
Python ããã®ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ããæ¹æ³ã¯ããã¤ãããã¾ãããããã§ã¯ Anaconda ã使ã£ã¦ã¤ã³ã¹ãã¼ã«ããæ¹æ³ãç´¹ä»ãã¾ãã ç§ã®å¨ãã§ã¯ Anaconda ã§ç°å¢æ§ç¯ããããã¨ã¨ Python ã³ãã¥ããã£æ¨æºã®æ¹æ³ãã¨ããã¨ã®æ¯éã«ã¤ãã¦ã®è°è«ãããè¦ããã¾ããèªåã®ç®çã«ãã£ããã®ãé¸æããã°è¯ãã¨æãã¾ãããåå¿è ã«ã¨ã£ã¦ã©ã¡ããç®çã«å¶ããã®ããå¤æããã®ã¯é£ãããã¨ããããã¾ããã 以ä¸ã«ãã£ã¹ããªãã¥ã¼ã¿ã¼ã¨ã㦠Anaconda (Continuum Analytics 社) ãæä¾ãã¦ãã価å¤ã«ã¤ãã¦ç§è¦ãã¾ã¨ãã¾ããã Anaconda 㯠Environment Isolation Tool (ç°å¢åé¢ãã¼ã«) ã§ã¯ãªã ä¸æ¹ã§ Python ã³ãã¥ããã£å ¬å¼ã®ãã¤ããªã¼ãã£ã¹ããªãã¥ã¼ã·ã§ã³ãæä¾ãããã¼ã«ã§ãã wheel ãå å®ãã¦ãã¾ããã
Ubuntuãªã©ã®ãã£ã¹ããªãã¥ã¼ã·ã§ã³ãMacã«ã¤ã³ã¹ãã¼ã«ããã¨ãã¯ããããããVirtualBoxãªã©ã®ä»®æ³åã½ãããå°å ¥ããå¿ è¦ãããã¾ãã ããã§ã¯ãUbuntuãMacã§ä½¿ãããæ¹ã«åãã¦ã irtualBoxã®å°å ¥æ¹æ³ Ubuntuã®å°å ¥æ¹æ³ ã«ã¤ãã¦ãããããã解説ãã¾ãï¼ VirtualBoxã¨ã¯ï¼ Ubuntuã¨ã¯ï¼ VirtualBoxã¨Ubuntuã®ãã¦ã³ãã¼ã VirtualBoxã®ãã¦ã³ãã¼ã VirtualBoxã®ã¤ã³ã¹ãã¼ã« Ubuntuã®ãã¦ã³ãã¼ã ä»®æ³ãã·ã³ã®è¨å® â ä»®æ³ãã·ã³ã®è¨å® â¡ãååã¨ãªãã¬ã¼ãã£ã³ã°ã·ã¹ãã ãã®è¨å® â¢ãã¡ã¢ãªã¼ãµã¤ãºãã®è¨å® â£ããã¼ããã£ã¹ã¯ãã®è¨å® â¤ããã¼ããã£ã¹ã¯ã®ãã¡ã¤ã«ã¿ã¤ããã®è¨å® â¥ãç©çãã¼ããã£ã¹ã¯ã«ããã¹ãã¬ã¼ã¸ãã®è¨å® â¦ããã¡ã¤ã«ã®å ´æã¨ãµã¤ãºããã®è¨å® Ubuntuã®ã¤ã³ã¹ãã¼ã« â æºå â¡ãã¤
æ¡ä»¶å¼ã¨ç¹°ãè¿ãã«ããã¹ã¯ãªããã®å¶å¾¡ æ¡ä»¶å¤æ å¼æ°ã«ãã£ã¦å®è¡æã«ãã©ã¡ã¼ã¿ãä¸ãããã¨ãã§ããããã«ãªãã¾ããã次ã«æ¬²ãããªãã®ã¯ãæ¡ä»¶å¤æã§ããããã¤ã¾ããç¹å®ã®æ¡ä»¶ãæºããããã¨ãã ãã³ãã³ããå®è¡ããã¨ãããã¨ã§ãããã®ããã®æ§æããifæãã§ã ã¨ããæ§é ã§ä½¿ãã¾ãããã®ãã¡ãelifãã¯ãªãã¦ãããã§ããã好ããªã ãç¹°ãè¿ããã¨ãã§ãã¾ããã¾ãããelseãã¯ä½¿ããªãããããã¯1åã ã使ãã¾ãã ããã§æ³¨æãå¿ è¦ãªã®ã¯ãæ¡ä»¶ãå¼ã§ã¯ãªãæã§ãããã¨ã§ããããªãã¡ãä¸è¬çãªçå½ã«ãã£ã¦å®è¡ãããããªããã決å®ããã®ã§ã¯ãªãã®ã§ããã§ã¯ä¸ä½ä½ããã£ã¦å¤æããã®ãã¨ããã¨ãå®è¡ããæã®ãçµäºã¹ãã¼ã¿ã¹ãã§ãã Linuxã§ã¯ãããããå®è¡ãã¡ã¤ã«ãçµäºæã«èªåèªèº«ãå¼ã³åºããããã»ã¹ã«å¯¾ãã¦æ´æ°ã®ã³ã¼ããè¿ãã¾ãããããçµäºã¹ãã¼ã¿ã¹ã§ãæ®éã¯æ£å¸¸ã«çµäºããã¨ãã«ã0ãããã¨ã©ã¼
æ¨é¡ã®ãã¼ããä»ã¾ã§ãªãã¤ã¬ã¯ã使ã£ã¦ã¾ã©ãã£ããããã¨ãã¦ããã # sed -e "s/AAA/ZZZ/g" INFILE.txt > OUTFILE.txt # cp OUTFILE.txt INFILE.txt ã¤ã¾ããä¸åº¦OUTFILE.txtã«ç½®æå 容ãåãåºãã¦ãããOUTFILE.txtããªãªã¸ãã«ã®INFILE.txtã«åæ ãã¨ããããæ¹ããããï¼-iãªãã·ã§ã³ã使ãã°æç¶ã¹ãã¼ãã«ã§ãããã¨ãä»ããç¥ãã # sed -i -e "s/AAA/ZZZ/g" INFILE.txt ããã ãã§ã対象ãã¡ã¤ã«ãä¸æ¸ãç·¨éããããããã«ã¯ã¡ãã£ã¨æåã 以ä¸ã®ããã«ããã°ããã¯ã¢ãããã¡ã¤ã«ãã¨ã£ã¦ãããã-iã¨ããã«ã¯ã©ã¼ãã¼ã·ã§ã³ã®éã¯è©°ããã # sed -i".org" -e "s/AAA/ZZZ/g" INFILE.txt ãããã©ãããæã«ä½¿ããããã¨ããã¨ãé常ã®
ã·ã§ã«ã¹ã¯ãªããå ¥éã¨ãã¦, åºæ¬çãªæ¸ãæ¹ãã¾ã¨ãã¾ãã. é·ãã§ãã, 1ãã¼ã¸ã«ã¾ã¨ãã¦ã¿ã¾ãã. è¯ãã£ããç®æ¬¡ãåèã«ãã¦ã覧ã«ãªã£ã¦ä¸ãã. ç®æ¬¡ ã·ã§ã«ã¹ã¯ãªããã¨ã¯ ä½ãæ¹, å®è¡ã®ä»æ¹ ã³ã¡ã³ã ã¦ã¼ã¶ã¼ããã®ãã¼ãã¼ãå ¥åãåãä»ãã å¤æ° é常ã®å¤æ° ç¹å¥ãªå¤æ° æ¼ç®å æ°å¤è¨ç®æ¼ç®å æ¯è¼æ¼ç®å ã³ãã³ããç¹ããæ¼ç®å æ¡ä»¶æã«ä½¿ããæ¯è¼æ¼ç®å æ¡ä»¶æ å¶å¾¡æ§æ(åå²) ifæ caseæ å¶å¾¡æ§æ(ã«ã¼ã) foræ whileæ untilæ selectæ æååå¦ç æååç½®æ åé¤ è¤æ°è¡ã®ããã¹ãã®åºå(ãã¢ããã¥ã¡ã³ã) é¢æ° ã·ã§ã«ã¹ã¯ãªããã¨ã¯ ã·ã§ã«ã¹ã¯ãªããã¨ã¯, ã·ã§ã«ã®åä½ãã¾ã¨ãã¦è¨è¿°ããã¹ã¯ãªããã®ãã¨ã§ã. 決ããããææ³ã«ãããã£ã¦å¦çãè¨è¿°ãããã¨ã«ãã£ã¦, ã·ã§ã«ã§ã®å¦çãã¾ã¨ãã¦è¡ã£ãã, ä½æ¥ãèªååã§ããããã¾ã(ä¾ è¤æ°
awkã¨ãããå¤ãããã®ã¹ã¯ãªããè¨èªããããï¼1977å¹´çã¾ããèªã¿æ¹ã¯ããªã¼ã¯ãã§ãããã¨ã¤ã»ãããªã¥ã»ã±ã¤ã§ã¯ãªãï¼man awkãPDFã«å¤æãã¦ã¿ãã¨ããã£ãã®3ãã¼ã¸å¼·ãããªãã $ man -t awk|pstopdf -i -o ~/Downloads/awk.pdf ã¨ã¦ãã·ã³ãã«ãªè¨èªä»æ§ã§ã¯ããããawkã«ã¯å¿ è¦ååãªè¡¨ç¾åããããç¹ã«ããã¹ããå¦çããå ´é¢ã«ããã¦ã¯ãæå°éã®ã·ã³ãã«ãªè¨è¿°ã§ãæ°ã®å©ããå¦çãç´ æ©ãããªããç¡é§ã®ãªãawkã¯ã³ã©ã¤ãã¼ãè¦ãã¨ããã種ã®æåãè¦ãããawk以éã«çã¾ããã¹ã¯ãªããè¨èªã¯ãå°ãªãããawkã®å½±é¿ãåãã¦ããã¨æãããã awkãç¥ããã¨ã§ãééããªã幸ç¦åº¦ã¯ä¸ããã¨æãããã¤ããã£ã¨ãç¥ã£ã¦ã¦è¯ãã£ããã¨æããæãæ¥ãã¯ãããã£ã¨ãã£ã¨ãawkãç¥ããããªã£ã¦ããã åºæ¬åä½ awkã®åºæ¬åä½ã¯ãã¨ã£ã¦ãã·ã³ãã«ã§ããã
ãã¼ã¿ãã¡ã¤ã«å¦çã«ä¾¿å©ãªUNIXã³ãã³ã ï¼ä¸é¨å·¥äºä¸ãé 次æ¡å¼µäºå®ï¼ ããã§ã¯ããã¼ã¿ãã¡ã¤ã«å¦çã«ä¾¿å©ãªUNIXã³ãã³ãã®ç´¹ä»ãè¡ãã¾ãã 使ç¨ç®çããæ¢ã - å®ä¾é - è¤æ°ã®ãã¡ã¤ã«ããã£ã¤ããã ãããã¡ã¤ã«ã®å¾ãã«æ¬¡ã®ãã¡ã¤ã«ãå ¥ããå ´åãcat åç´ã«ãã¡ã¤ã«ã®æåããé ã«è¡å士ããã£ã¤ãã¦ãã¾ãå ´åãpaste ç¹å®ã®è¡ã仲ç«ã¡ã¨ãã¦ãã¡ã¤ã«ããã£ã¤ããå ´åãjoin ãã¡ã¤ã«ã®ããè¡ãèªã¿é£ã°ããã awk ãã¡ã¤ã«ã®ç©ºè¡ãèªã¿é£ã°ããã awk ãã¡ã¤ã«ã®ããåã¨ããåãç¨ãã¦æ¼ç®ãè¡ããã awk ãã¡ã¤ã«ã®ç¹å®ã®æåãå¥ã®æåã«å¤æï¼ç½®æï¼ããã sed ãã¼ã¿ã®ãã©ã¼ããããæããã awk 1ã01ã®ããã«ãé ã«ã¼ããã¤ããã(ã¼ãããã£ã³ã°) 0.035ã3.5E-2ã®ããã«ãææ°è¡¨ç¤ºã«ãããããªã©ã ãã¡ã¤ã«åããããã£ã¬ã¯ããªåãããã¯æ¡å¼µåãåãé¤ã
while æã®ä½¿ç¨æ¹æ³ while æã¨ã¯ï¼ while æã¯ãããæ¡ä»¶ãæãç«ã£ã¦ããéã®ã¿ç¹°ãè¿ãå¦çãå®è¡ãããã¨ãã£ããä¸å®åã®ç¹°ãè¿ãå¦çãè¡ãå ´åã«ä½¿ç¨ããã«ã¼ãå¶å¾¡æã§ããã ä¸è¬çã«å¦çåæ°ãæ確ã§ããå ´åã«ã¯ for æãç¨ããããå¦çåæ°ãéå§æç¹ã§ã¯ä¸æ確ãªå ´åã¯ãã® while æãç¨ããã while æã¯å§ãã«æå®ãããæ¡ä»¶å¼ã®çµäºã¹ãã¼ã¿ã¹ãå¤å®ããçµæãçã§ããå ´åã®ã¿ã«ã¼ãå¦çãç¶ç¶ãããã«ã¼ãæ¯ã«æ¡ä»¶å¼ãè©ä¾¡ãçã§ããã°å¦çãå®è¡ããããããç¹°ãè¿ããæ¡ä»¶å¼ãå½ã«ãªã£ãæç¹ã§ã«ã¼ãå¦çããçµäºããã â å¦çåæ°ãéå§æç¹ã§ã¯ä¸æ確ãªã«ã¼ãå¦çã«ã¯ while æã使ç¨ããã while æã«ã¯ã«ã¼ãã®ç¶ç¶æ¡ä»¶ã¨ãªãæ¡ä»¶å¼ãæå®ãããæ¡ä»¶å¼ã«ã¯ test ã³ãã³ãã使ç¨ããã®ãä¸è¬çã ããå½ç¶ãã®ä»ã®ã³ãã³ãã使ç¨å¯è½ã§ããã while æã«ããæ¡ä»¶
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}