linux便利なコマンドページ
sorry Japanese only
最終更新日 2007/01/06
page size = Mbyte

余り使わないので忘れてしまいがちですが、覚えておくと便利なコマンド集のページです。

findと tarを組み合わせた backup

find . -name "*.txt" -exec tar uvf text.tar {} \;
現在のディレクトリー以下にある *.txtを text.tarファイルへ tarでまとめる

find . -name "*.html" -exec tar uvf text.tar {} \;
現在のディレクトリー以下にある *.htmlを、先ほどまとめた text.tarに追加しながら tarでまとめる

find . -newer ./sitemap.xml -type f -exec tar rvf backup.tar {} \;
sitemap.xmlが変更された日付以降に書き換えられたファイルのみを tarで backup.tarファイルへまとめる

tarを使った部分的除外のバックアップ

[root]# cat jyogai.txt
keiri
himitu/*.txt
*.dat
[root]# tar cvXf jyogai.txt /tmp/myhome.tar /home/localhost
/home/localhost以下を /tmp/myhome.tarに tarでまとめるが、その中で除外するファイル、ディレクトリーを jyogai.txt内で指定
/home/localhost/keiriディレクトリー以下全て除外
/home/localhost/himituディレクトリー内の *.txtを除外
/home/localhost以下の *.datを除外

CGIが internal server errorの時

2004/10/03

CGIを実行して internal server error 500が出た時、どこがどう悪いのか?が分からず直すのが非常に大変なんですが、以下のコマンドを実行すると、どの辺が悪いのか?を絞り込むことが出来ます。
[root]# perl -c check-ip-ng.cgi
String found where operator expected at check-ip-ng.cgi line 3, near "plint "Content-type: text/html\n\n""
        (Do you need to predeclare plint?)
syntax error at check-ip-ng.cgi line 3, near "plint "Content-type: text/html\n\n""
check-ip-ng.cgi had compilation errors.

こんな CGIを試した時のエラー表示です。
#!/usr/bin/perl

plint "Content-type: text/html\n\n";
print "あなたの<br>";
printと plintを間違えてます。

linuxの perl、win32の ActivePerlどちらも同じように確認することが出来ました。
(但し 1行目の #!/usr/bin/perlを記述ミスしていても、1行目だけはエラー表示をしてくれないようです)

tarを使ったコピー

2004/09/29

[root]# cd /hoge
[root]# tar cf - . | ( cd /hoge2 ; tar xvf - )

/hoge以下を /hoge2以下へ、grp,own,modeなどを変えずに一括コピーを行う

15227
戻る