ablog

不器用で落着きのない技術者のメモ

dd の出力をパイプで gzip に渡して圧縮する

-bash-3.00$ perl -le 'print for(1...100)'>foo.txt
-bash-3.00$ dd if=foo.txt of=bar1.txt bs=1024k count=10
0+1 records in
0+1 records out
-bash-3.00$ dd if=foo.txt bs=1024k count=10>bar2.txt
0+1 records in
0+1 records out
-bash-3.00$ dd if=foo.txt bs=1024k count=10|gzip -c>bar3.txt.gz
0+1 records in
0+1 records out
-bash-3.00$ gunzip bar3.txt.gz 
-bash-3.00$ diff foo.txt bar1.txt 
-bash-3.00$ diff foo.txt bar2.txt 
-bash-3.00$ diff foo.txt bar3.txt 
-bash-3.00$ ls -l *.txt
-rw-r--r--   1 oracle   oinstall     292 Apr 14 16:01 bar1.txt
-rw-r--r--   1 oracle   oinstall     292 Apr 14 16:01 bar2.txt
-rw-r--r--   1 oracle   oinstall     292 Apr 14 16:02 bar3.txt
-rw-r--r--   1 oracle   oinstall     292 Apr 14 16:00 foo.txt
-bash-3.00$ head -3 bar3.txt 
1
2
3
-bash-3.00$ tail -3 bar3.txt 
98
99
100

of をつけなければ標準出力に出力されるんですね。