「シェルスクリプト」の編集履歴(バックアップ)一覧はこちら

シェルスクリプト」(2014/06/04 (水) 07:45:44) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

* シェルスクリプトで関数 -http://merry.whitesnow.jp/SEMICMD/SECTION6/section6_7.html * シェルスクリプトで2次元配列 -http://www.kurobuti.com/blog/?p=4880 -http://mstssk.blogspot.jp/2009/04/eval-command-in-bash-shell-script.html * 同じ構成のディレクトリ間でdiffをとる #!/usr/bin/bash dst_path=$1 for diff_file in $(cat tmp/diff_list.txt); do diff -cw ${diff_file} ${dst_path}/${diff_file} > diff_tmp.txt if [ $? -eq 1 ]; then echo "[*] ${diff_file}" cat diff_tmp.txt fi done * "find -exec grep" と "find + xargs grep" の速さの違い 大量に"*.c"のファイルがある場所で、以下のコマンドを実行 $ time find . -type f -name '*.c' -exec grep -iHn 'foo' {} \; ... ... ... real 0m11.588s user 0m5.996s sys 0m0.588s $ time find . -type f -name '*.c' | xargs grep -iHn 'foo' ... ... ... real 0m8.699s user 0m8.489s sys 0m0.096s * カレントディレクトリ以下のディレクトリサイズの総合計を得る #!/bin/bash IFS=" " dirsize=0 for dir in $(find . -type d); do current_dirsize=$(ls -l "$dir" | sed -n '1p' | awk '{print $2}') dirsize=$(($dirsize + $current_dirsize)) done echo "$dirsize" duコマンドで得られるのはブロックサイズなので、つくったもの。 「ls -l」でそのディレクトリ直下のファイルサイズ合計が得られるので、 それを全てのディレクトリに対して行い、和をとっている。 しかし、遅いので使うべきでないです。 http://sonic64.com/2004-05-26.html こっちの記事のやり方の方がいい。 他に参考: -http://deginzabi163.wordpress.com/2010/05/10/%E8%A6%9A%E6%9B%B8%E3%82%B9%E3%83%9A%E3%83%BC%E3%82%B9%E3%82%84%E7%A9%BA%E7%99%BD%E3%82%92%E5%90%AB%E3%82%80%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E5%90%8D%E3%81%AB%E5%AF%BE%E5%BF%9C%E3%81%A7%E3%81%8D/
*シェルスクリプトでやってみた系 -[[文字を回転させて重ねるときれいな模様になる>http://jarp.does.notwork.org/diary/201405c.html#201405241]] -[[bashで高機能なブログを作れるスクリプト>http://blog.sachin21.info/entry/2014/05/20/224909]] * シェルスクリプトで関数 -http://merry.whitesnow.jp/SEMICMD/SECTION6/section6_7.html * シェルスクリプトで2次元配列 -http://www.kurobuti.com/blog/?p=4880 -http://mstssk.blogspot.jp/2009/04/eval-command-in-bash-shell-script.html * 同じ構成のディレクトリ間でdiffをとる #!/usr/bin/bash dst_path=$1 for diff_file in $(cat tmp/diff_list.txt); do diff -cw ${diff_file} ${dst_path}/${diff_file} > diff_tmp.txt if [ $? -eq 1 ]; then echo "[*] ${diff_file}" cat diff_tmp.txt fi done * "find -exec grep" と "find + xargs grep" の速さの違い 大量に"*.c"のファイルがある場所で、以下のコマンドを実行 $ time find . -type f -name '*.c' -exec grep -iHn 'foo' {} \; ... ... ... real 0m11.588s user 0m5.996s sys 0m0.588s $ time find . -type f -name '*.c' | xargs grep -iHn 'foo' ... ... ... real 0m8.699s user 0m8.489s sys 0m0.096s * カレントディレクトリ以下のディレクトリサイズの総合計を得る #!/bin/bash IFS=" " dirsize=0 for dir in $(find . -type d); do current_dirsize=$(ls -l "$dir" | sed -n '1p' | awk '{print $2}') dirsize=$(($dirsize + $current_dirsize)) done echo "$dirsize" duコマンドで得られるのはブロックサイズなので、つくったもの。 「ls -l」でそのディレクトリ直下のファイルサイズ合計が得られるので、 それを全てのディレクトリに対して行い、和をとっている。 しかし、遅いので使うべきでないです。 http://sonic64.com/2004-05-26.html こっちの記事のやり方の方がいい。 他に参考: -http://deginzabi163.wordpress.com/2010/05/10/%E8%A6%9A%E6%9B%B8%E3%82%B9%E3%83%9A%E3%83%BC%E3%82%B9%E3%82%84%E7%A9%BA%E7%99%BD%E3%82%92%E5%90%AB%E3%82%80%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E5%90%8D%E3%81%AB%E5%AF%BE%E5%BF%9C%E3%81%A7%E3%81%8D/

表示オプション

横に並べて表示:
変化行の前後のみ表示: