commandlinefu.comã§è¦ã¤ãã便å©ã»é¢ç½Linuxã³ãã³ã使ç¨ä¾
- commandlinefu.com
- ã³ãã³ã使ç¨ä¾
- ^foo^bar
- mount | column -t
- time read (ctrl-d to stop)
- echo "You can simulate on-screen typing just like in the movies" | pv -qL 10
- mv filename.{old,new}
- diff <(sort file1) <(sort file2)
- !*
- !:-
- fc
- date -d@1234567890
- ps awwfux | less -S
- bind -P
- mkdir -p work/{d1,d2}/{src,bin,bak}
- showkey -a
- ccze
- grep . filename > newfilename
- grep -Fx -f file1 file2
- grep . *
- kill -9 $$
- tail -f file | while read; do echo "$(date +%T.%N) $REPLY"; done
- set -o vi
commandlinefu.com
commandlinefu.comã¨ãã便å©ãªã³ãã³ã使ç¨ä¾ï¼ã¯ã³ã©ã¤ãã¼ï¼ãå
±æãããµã¤ãããã£ãã®ã§æ°ã«ãªã£ãã³ãã³ãã試ãã¦ã¿ãã
ãµã¤ãã§ã¯ã¦ã¼ã¶ãæ票ã§ããããã«ãªã£ã¦ãã¦soted byãvotesã«ããã¨äººæ°é ã«é²è¦§å¯è½ãæè¿ã§ãã³ãã³ã使ç¨ä¾ãæ稿ããã¦ããã2009å¹´ã2010å¹´é ã«æ稿ããããã®ã人æ°ãªã®ã§ãã®é ã«è©±é¡ã ã£ãã®ã ãããã
ã³ãã³ã使ç¨ä¾
^foo^bar
ç´åã®ã³ãã³ããç½®æã^
ã1ã¤ã ã¨åé¤ã
$ echo "abc" abc $ ^bc^de ade $ echo "abc" abc $ ^bc a
mount | column -t
表形å¼ã«æ´å½¢ã
$ mount sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) devtmpfs on /dev type devtmpfs (rw,nosuid,size=1931660k,nr_inodes=482915,mode=755) $ mount | column -t sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) devtmpfs on /dev type devtmpfs (rw,nosuid,size=1931660k,nr_inodes=482915,mode=755)
ã»ãã¬ã¼ã¿ãæå®ãããã¨ãã§ããã®ã§csvãã¡ã¤ã«ãæ´å½¢å¯è½ã
$ column -t -s, < test.csv 1 a 10 ab 100 abc
time read (ctrl-d to stop)
ç°¡æã¹ãããã¦ã©ããã¨ãããã¨ããããCtrl-d
ãæ¼ãã¨åæ¢ã
$ time read real 0m4.534s user 0m0.000s sys 0m0.000s
echo "You can simulate on-screen typing just like in the movies" | pv -qL 10
誰ããæã£ã¦ããããã«ã¿ã¤ãã³ã°ãã·ãã¥ã¬ã¼ãããããã®å ´åã¯1ç§ã«10æåãã¤ã
$ echo "You can simulate on-screen typing just like in the movies" | pv -qL 10 You can simulate on-screen ty
pvã¯pipe viewerã®ç¥ã使ããªãå ´åã¯ä¸è¨ã³ãã³ãã§ã¤ã³ã¹ãã¼ã«ï¼CentOSã®å ´åï¼ã
$ sudo yum install pv
æ¬æ¥ã¯ä»¥ä¸ã®ããã«ãã¤ãã®é²æã確èªããã³ãã³ãã
$ pv access.log | gzip > access.log.gz 254MiB 0:00:08 [34.9MiB/s] [==============> ] 29% ETA 0:00:18
使ãæ¹ã¯ä¸è¨è¨äºãåç
§ã
wonderwall.hatenablog.com
mv filename.{old,new}
æ¡å¼µåå¤æ´ãããã¯ã¢ãããã¡ã¤ã«ä½æãªã©ã
$ cp file.txt{,.bak}
diff <(sort file1) <(sort file2)
ã½ã¼ãããã¦ããªããã¡ã¤ã«ãæ¯è¼ããããã³ãã©ãªã®ãã¡ã¤ã«ãä½æããªãã¦ããã
!*
ç´åã®ã³ãã³ãã®ãã©ã¡ã¼ã¿ãåå©ç¨ããï¼å é ã®ã¿é¤ãï¼ã
$ vi cd work $ !* cd work
!:-
ç´åã®ã³ãã³ãã®æå¾ã®ãã©ã¡ã¼ã¿ä»¥å¤ãåå©ç¨ããã
$ curl -sS -o /tmp/test http://httpbin.org $ !:- http://www.commandlinefu.com
ã¨å®è¡ããã¨ãä¸è¨ã³ãã³ãã¨åãã
$ curl -sS -o /tmp/test http://www.commandlinefu.com
fc
ç´åã®ã³ãã³ããã¨ãã£ã¿ã§ç·¨éã
date -d@1234567890
UnixTimeã®å¤æã
$ date -d@1234567890 2009å¹´ 2æ 14æ¥ åææ¥ 08:31:30 JST
ps awwfux | less -S
ããã»ã¹ã®è¦ªåé¢ä¿ã表示ã
root 20502 0.0 0.1 140780 4956 ? Ss 7æ29 0:00 \_ sshd: vagrant [priv] vagrant 20504 0.0 0.0 142012 3328 ? S 7æ29 0:03 \_ sshd: vagrant@pts/0 vagrant 20505 0.0 0.1 155292 6220 pts/0 Ss 7æ29 0:13 \_ -zsh vagrant 11105 0.0 0.0 115660 2432 pts/0 S 20:39 0:00 \_ /bin/bash vagrant 11262 0.0 0.0 139632 1708 pts/0 R+ 21:03 0:00 \_ ps awwfux
bind -P
ãã¼ãã¤ã³ã表示ã
$ bind -P abort can be found on "\C-g", "\C-x\C-g", "\e\C-g". accept-line can be found on "\C-j", "\C-m". alias-expand-line is not bound to any keys
mkdir -p work/{d1,d2}/{src,bin,bak}
ãã£ã¬ã¯ããªããªã¼ä½æã
$ mkdir -p work/{d1,d2}/{src,bin,bak} $ ls -R work/ work/: d1 d2 work/d1: bak bin src work/d1/bak: work/d1/bin: work/d1/src: work/d2: bak bin src work/d2/bak: work/d2/bin: work/d2/src:
showkey -a
æ¼ãããã¼ã®ãã¼ã³ã¼ãã表示ã
$ showkey -a Press any keys - Ctrl-D will terminate this program a 97 0141 0x61 1 49 0061 0x31 ! 33 0041 0x21
ccze
ãã°ã«è²ãä»ããã
$ tail -f /var/log/messages | ccze -A $ tail -f /var/log/exim4/mainlog | ccze -A
使ããªãå ´åã¯ä¸è¨ã³ãã³ãã§ã¤ã³ã¹ãã¼ã«ï¼CentOSã®å ´åï¼ã
$ sudo yum install ccze
使ãæ¹ã¯ä¸è¨è¨äºãåç
§ã
wonderwall.hatenablog.com
grep . filename > newfilename
空ç½è¡ãåé¤ãã¦åºåã
grep -Fx -f file1 file2
å ±éè¡ã表示ã
$ cat test1.txt 1 2 3 $ cat test2.txt 3 4 5 $ grep -Fx -f test1.txt test2.txt 3
grep . *
ãã¡ã¤ã«åä»ãã§catãããå ´åã
$ grep . * test1.txt:1 test1.txt:2 test1.txt:3 test2.txt:a test2.txt:b test2.txt:c
kill -9 $$
ã³ãã³ãå±¥æ´ãæ®ããã«exitã$$ã¯ãã°ã¤ã³ãã¦ããã·ã§ã«ã®ããã»ã¹IDã
詳ããã¯ä¸è¨ãªã³ã¯åç
§ã
qiita.com
tail -f file | while read; do echo "$(date +%T.%N) $REPLY"; done
ã¿ã¤ã ã¹ã¿ã³ãä»ãã§tail -f
ã
$ tail -f file | while read; do echo "$(date +%T.%N) $REPLY"; done 21:26:37.785311678 test1 21:26:40.622065180 test2 21:26:43.435610201 test3
set -o vi
ã³ãã³ãå
¥åãviã¢ã¼ãã«ããã
ç¾å¨ã®ãªãã·ã§ã³ã¯ä¸è¨ã§ç¢ºèªå¯è½ã
$ set -o
å ã«æ»ãå ´åã
$ set -o emacs