oga's tools
修訂 | 1905d4b6a7232abccea4037696f841a0bfe08fbf (tree) |
---|---|
時間 | 2014-01-04 10:58:23 |
作者 | oga <oga@mxg....> |
Commiter | oga |
add shell script tools
@@ -0,0 +1,3 @@ | ||
1 | +#!/bin/sh | |
2 | +echo ")B" | |
3 | +echo "%1b(B" |ht |
@@ -0,0 +1,43 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# usage : add ファイル名 [加算項目の位置] | |
4 | +# | |
5 | +# 先頭に#がある行はコメントとみなします。 | |
6 | +# | |
7 | +if [ -z "$1" ];then | |
8 | + echo "usage : add ファイル名 [加算項目の位置]" | |
9 | + exit 1 | |
10 | +fi | |
11 | + | |
12 | +if [ "$1" = "-" ]; then | |
13 | + FILE= | |
14 | +else | |
15 | + FILE=$1 | |
16 | +fi | |
17 | + | |
18 | +if [ -z "$2" ];then | |
19 | + CLM=1 | |
20 | +else | |
21 | + CLM=$2 | |
22 | +fi | |
23 | + | |
24 | +grep -v -e "^#" -e "^$" $FILE > /tmp/add$$ | |
25 | + | |
26 | +trap "rm /tmp/add$$; exit 1" 0 1 2 9 15 | |
27 | + | |
28 | +KEI=0 | |
29 | +export KEI | |
30 | +while read LINE | |
31 | +do | |
32 | +# echo $LINE | |
33 | + DATA=`echo $LINE |awk -v item=$CLM '{ print $item }'` | |
34 | + if [ "$DATA" = "" ]; then | |
35 | + echo "skip! <<$LINE>>" | |
36 | + else | |
37 | + KEI=`expr $DATA + $KEI` | |
38 | + echo "$DATA / $KEI" | |
39 | + fi | |
40 | +done < /tmp/add$$ | |
41 | + | |
42 | +#rm /tmp/add$$ | |
43 | + |
@@ -0,0 +1,28 @@ | ||
1 | +#!/bin/sh -x | |
2 | +# | |
3 | +# ユーザ追加 | |
4 | +# | |
5 | + | |
6 | +# | |
7 | +# mkuser <user_name> <uid> <group_name> | |
8 | +# | |
9 | +mkuser() | |
10 | +{ | |
11 | + USER=$1 | |
12 | + USER_ID=$2 | |
13 | + GROUP=$3 | |
14 | + | |
15 | + mkdir /home/$USER | |
16 | + useradd -u $USER_ID -g $GROUP -d /home/$USER -s /bin/tcsh $USER | |
17 | + chown $USER:$GROUP /home/$USER | |
18 | + | |
19 | + # copy dot files | |
20 | + echo "source ~oga/com_env" > /home/$USER/.cshrc | |
21 | + cp /home/oga/.ueyamanrc /home/$USER | |
22 | + cp /home/oga/.vimrc /home/$USER | |
23 | + chown $USER:$GROUP /home/$USER/.[cuv]* | |
24 | + return | |
25 | +} | |
26 | + | |
27 | +mkuser newuser 9001 users | |
28 | + |
@@ -0,0 +1,33 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# characteristic clock (world version) | |
4 | +# | |
5 | +# by oga | |
6 | +# | |
7 | + | |
8 | +#EOPT=-e | |
9 | + | |
10 | +if [ "$1" = "-h" ]; then | |
11 | + echo "usage: cclock [<tz>]" | |
12 | + echo " tz : -12 ... +12" | |
13 | + echo " Japan : -9" | |
14 | + exit 1 | |
15 | +fi | |
16 | + | |
17 | +if [ "$1" != "" ]; then | |
18 | + TZ=XXX$1 | |
19 | + export TZ | |
20 | + echo " TZ : $TZ" | |
21 | +fi | |
22 | + | |
23 | +echo $EOPT " @=====================@\n" | |
24 | +echo $EOPT " @=====================@\n\033M" | |
25 | + | |
26 | +while : | |
27 | +do | |
28 | + echo $EOPT "\033M\033M\c" | |
29 | + date +" | %Y/%m/%d %H:%M:%S |" | |
30 | + echo "" | |
31 | + sleep 1 | |
32 | +done | |
33 | + |
@@ -0,0 +1,20 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# characteristic clock | |
4 | +# | |
5 | +# by oga | |
6 | +# | |
7 | + | |
8 | +#echo " @=====================@\n" | |
9 | +#echo " @=====================@\n\033M" | |
10 | + | |
11 | +echo "\n\n\n\n\n\n\n\n" | |
12 | + | |
13 | +while : | |
14 | +do | |
15 | + #echo "\033M\033M\033M\033M\033M\033M\033M\033M\c" | |
16 | + #banner `date +%H:%M:%S` |sed "s/\$/ /" | |
17 | + #echo -e "\033M\033M\033M\033M\033M\033M\033M\033M\c" | |
18 | + banner -w 40 `date +%H:%M:%S` |sed "s/\$/ /" | |
19 | + sleep 1 | |
20 | +done |
@@ -0,0 +1,24 @@ | ||
1 | +#!/bin/sh | |
2 | + | |
3 | +if [ "$1" = "" ]; then | |
4 | + UPDATE=5 | |
5 | +else | |
6 | + UPDATE=$1 | |
7 | +fi | |
8 | + | |
9 | +while : | |
10 | +do | |
11 | + XX=`uptime | sed "s/.*load//" | awk '{ print $2 }' |sed "s/\.//" |sed "s/,//" ` | |
12 | + XX=`expr $XX / 10` | |
13 | + if [ $XX -gt 130 ]; then | |
14 | + XX=130 | |
15 | + fi | |
16 | + if [ $XX -eq 0 ]; then | |
17 | + XX=1 | |
18 | + fi | |
19 | + #echo "`hostname`|\c" | |
20 | + echo -n "`hostname`|" | |
21 | + printf "%3d|" $XX | |
22 | + echo "OOOOOOOOO|OOOOOOOOO|OOOOOOOOO|OOOOOOOOO|OOOOOOOOO|OOOOOOOOO|OOOOOOOOO|OOOOOOOOO|OOOOOOOOO|OOOOOOOOO|XXXXXXXXX|XXXXXXXXX|XXXXXXXXX|" |cut -c1-$XX | |
23 | + sleep $UPDATE | |
24 | +done |
@@ -0,0 +1,56 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# csv2tbl <filename> | |
4 | +# | |
5 | +# CSV をHTMLの TABLE形式にする。 96/06/24 V1.00 (C)1996, Moritaka Ogasawara. | |
6 | +# | |
7 | + | |
8 | +if [ "$1" = "-h" ]; then | |
9 | + #echo "usage : csv2tbl [-l|-r] [<filename>]" | |
10 | + echo "usage : csv2tbl [-l|-r]" | |
11 | + exit 1 | |
12 | +fi | |
13 | + | |
14 | +if [ "$1" = "-l" ]; then | |
15 | + FL=L | |
16 | + shift | |
17 | +fi | |
18 | +if [ "$1" = "-r" ]; then | |
19 | + FL=R | |
20 | + shift | |
21 | +fi | |
22 | + | |
23 | +TMP=/tmp/csv2tbl.tmp | |
24 | + | |
25 | +if [ -f $TMP ]; then | |
26 | + rm -f $TMP | |
27 | +fi | |
28 | + | |
29 | +echo '<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=1 WIDTH="90%">' | |
30 | + | |
31 | +while read LINE | |
32 | +do | |
33 | + echo -e " \c" | |
34 | + #echo $LINE |sed "s/^/<TR><TD>/" |sed "s/,/<\/TD><TD>/g" |sed "s/$/<\/TD>/" | |
35 | + if [ "$FL" = "L" ]; then | |
36 | + echo $LINE |sed -e 's@^@<TR><TD>@' -e 's@,@</TD><TD>@g' \ | |
37 | + -e "s@\$@</TD>@" | |
38 | + elif [ "$FL" = "R" ]; then | |
39 | + echo $LINE |sed -e 's/^/<TR><TD ALIGN="right">/' \ | |
40 | + -e 's/,/<\/TD><TD ALIGN="right">/g' -e "s/\$/<\/TD>/" | |
41 | + else | |
42 | + echo $LINE |sed -e 's/^/<TR><TD ALIGN="center">/' \ | |
43 | + -e 's/,/<\/TD><TD ALIGN="center">/g' -e "s/\$/<\/TD>/" | |
44 | + fi | |
45 | + touch $TMP | |
46 | +#done < $1 | |
47 | +done | |
48 | +echo "</TABLE>" | |
49 | + | |
50 | +if [ -f $TMP ]; then | |
51 | + rm -f $TMP | |
52 | + exit 0 | |
53 | +else | |
54 | + # no line | |
55 | + exit 1 | |
56 | +fi |
@@ -0,0 +1,46 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# カップめんタイマー | |
4 | +# | |
5 | +# 98/05/08 by おが☆ | |
6 | +# | |
7 | + | |
8 | +#ECHO="echo -e" # for bush | |
9 | +ECHO="echo" # for sh | |
10 | + | |
11 | +if [ "$1" = "" -o "$1" = "-h" ]; then | |
12 | + echo "usage: cupmen <min>" | |
13 | + exit 1 | |
14 | +fi | |
15 | + | |
16 | +SEC=`expr 60 \* $1` | |
17 | + | |
18 | +$ECHO " $1 分間のがまんです。" | |
19 | +$ECHO "" | |
20 | +$ECHO "" | |
21 | +$ECHO "\033M\033M" | |
22 | + | |
23 | +while [ $SEC -ne 10 ] | |
24 | +do | |
25 | + $ECHO " あと $SEC 秒です。 \033M" | |
26 | + sleep 10 | |
27 | + SEC=`expr $SEC - 10` | |
28 | +done | |
29 | + | |
30 | +while [ $SEC -ne 0 ] | |
31 | +do | |
32 | + $ECHO " あと $SEC 秒です。 \033M" | |
33 | + sleep 1 | |
34 | + SEC=`expr $SEC - 1` | |
35 | +done | |
36 | + | |
37 | +$ECHO " あと $SEC 秒です。 " | |
38 | +$ECHO "" | |
39 | + | |
40 | +$ECHO "\033[33m カップめん\007\c" | |
41 | +sleep 1 | |
42 | +$ECHO "\033[36mが\007\c" | |
43 | +sleep 1 | |
44 | +$ECHO "\033[34mできました。\007\033[0m" | |
45 | +$ECHO "" | |
46 | + |
@@ -0,0 +1,146 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# 指定ディレクトリのソースのうち変更のあるファイルのdiffをとり、 | |
4 | +# /tmp/diff_<uid>に出力する | |
5 | +# | |
6 | +# olddir : 旧ファイルのあるディレクトリ | |
7 | +# -f filename : 特定のファイルのみ行なう場合 | |
8 | +# -step : 各ファイルの修正ステップ数のみ取得する場合 | |
9 | +# | |
10 | +# 99/09/28 V1.01 -step support by oga | |
11 | +# 00/02/26 V1.02 "{" support (for vi) | |
12 | +# 00/09/04 V1.03 -diff <diff_cmd> | |
13 | +# 00/10/25 V1.04 -u(unified diff) support | |
14 | +# 00/11/04 V1.05 mgdiff support | |
15 | +# 01/02/02 V1.06 -f multifile support | |
16 | +# 02/02/24 V1.07 check delete file | |
17 | +# 04/03/08 V1.08 -u/-C 同時指定可とした | |
18 | +# 07/03/07 V1.09 -u/-C 同時指定NGとした | |
19 | +# | |
20 | + | |
21 | +WK=/tmp/diff_`id -u -n` | |
22 | +COPT=-C4 # diffの前後の行数 | |
23 | +UOPT= | |
24 | +DIFF=diff | |
25 | +STEP=0 | |
26 | + | |
27 | +if [ "$1" = "" -o "$1" = "-h" ]; then | |
28 | + echo "usage : diffd [-w] [-u] <olddir> [-step] [{-f filename ...| num<4>}]" | |
29 | + echo " <olddir> : 比較元ファイルのあるディレクトリ" | |
30 | + echo " -w : 空白を無視して差分をとる" | |
31 | + echo " -u : unified diff" | |
32 | + echo " -f : 指定ファイルのみ差分をとる" | |
33 | + echo " -step : 変更ステップ数表示" | |
34 | + echo " num : 差分の前後に出力する行数" | |
35 | + exit 1 | |
36 | +fi | |
37 | + | |
38 | +if [ "$1" = "-diff" ]; then | |
39 | + DIFF="$2" | |
40 | + shift | |
41 | + shift | |
42 | +fi | |
43 | + | |
44 | +if [ "$1" = "-w" ]; then | |
45 | + DIFF="$DIFF -w" | |
46 | + echo "★空白は無視して差分をとります" | |
47 | + shift | |
48 | +fi | |
49 | + | |
50 | +if [ "$1" = "-c" ]; then | |
51 | + COBOL=1 | |
52 | + echo "★COBOL option" | |
53 | + shift | |
54 | +fi | |
55 | + | |
56 | +if [ "$1" = "-u" ]; then | |
57 | + echo "★unified format で差分を取ります" | |
58 | + UF=1 | |
59 | + UOPT=-u | |
60 | + COPT= | |
61 | + shift | |
62 | +fi | |
63 | + | |
64 | +if [ "$1" = "-m" ]; then #V1.05 | |
65 | + MGDIFF=1 | |
66 | + shift | |
67 | +fi | |
68 | + | |
69 | +OLDDIR=$1 | |
70 | +shift | |
71 | + | |
72 | +if [ "$1" = "-step" ]; then #V1.01 | |
73 | + STEP=1 #V1.01 | |
74 | + shift #V1.01 | |
75 | +fi #V1.01 | |
76 | + | |
77 | +if [ "$1" = "-f" ]; then | |
78 | + shift | |
79 | + FILENM=$* | |
80 | + shift | |
81 | +else | |
82 | + if [ "$1" != "" -a "$UF" != "1" ]; then # V1.08-C V1.09-C | |
83 | + #if [ "$1" != "" ]; then | |
84 | + NUM=$1 | |
85 | + COPT=-C$1 | |
86 | + echo "★diffは前後 $NUM 行とります。" | |
87 | + shift | |
88 | + fi | |
89 | +fi | |
90 | + | |
91 | +if [ -f $WK ]; then | |
92 | + rm $WK | |
93 | +fi | |
94 | + | |
95 | +if [ "$FILENM" = "" ]; then | |
96 | + LIST=`ls $OLDDIR` | |
97 | +else | |
98 | + LIST=`(cd $OLDDIR; ls ${FILENM}* )` | |
99 | +fi | |
100 | + | |
101 | +for i in $LIST | |
102 | +do | |
103 | + echo $i |awk '{printf" %-16s: ",$1}' | |
104 | + | |
105 | + if [ ! -f $i ]; then | |
106 | + echo "<= 削除されました。" | |
107 | + continue | |
108 | + fi | |
109 | + | |
110 | + $DIFF $OLDDIR/$i $i > /dev/null | |
111 | + if [ $? -eq 1 ]; then | |
112 | + echo "変更されています。diffをとります。" | |
113 | + echo "{" >> $WK | |
114 | + echo "■ ファイル : `pwd`/$i" >> $WK | |
115 | + echo "<変更前>" >> $WK | |
116 | + echo " 省略" >> $WK | |
117 | + echo "" >> $WK | |
118 | + echo "<変更後>" >> $WK | |
119 | + | |
120 | + #$DIFF $COPT $OLDDIR/$i $i >> $WK | |
121 | + # diff: conflicting specifications of output style 抑止 V1.08-C | |
122 | + # -u は -Cの後ろにしないと無効になってしまう | |
123 | + $DIFF $COPT $UOPT $OLDDIR/$i $i 2>&1 |\ | |
124 | + grep -v "conflicting specifications of output style" >> $WK | |
125 | + | |
126 | + echo -e "\n" >> $WK | |
127 | + | |
128 | + if [ $STEP -eq 1 ]; then # V1.01 | |
129 | + c $WK # V1.01 | |
130 | + echo -e "\n" # V1.01 | |
131 | + rm $WK # V1.01 | |
132 | + fi # V1.01 | |
133 | + | |
134 | + if [ "$MGDIFF" = "1" ]; then # V1.05 | |
135 | + mgdiff $OLDDIR/$i $i | |
136 | + fi | |
137 | + | |
138 | + else | |
139 | + echo "変更ありません。" | |
140 | + fi | |
141 | +done | |
142 | +echo "終了!!" | |
143 | + | |
144 | +if [ $STEP -ne 1 ]; then | |
145 | + echo " 結果は ${WK} に出力しました。" | |
146 | +fi |
@@ -0,0 +1,59 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# dupdel | |
4 | +# | |
5 | +# 同じファイルがあったら片方を削除する。 | |
6 | +# | |
7 | +# 2003/11/22 V1.00 by oga. | |
8 | + | |
9 | +if [ "$1" = "-v" ]; then | |
10 | + shift | |
11 | + VF=1 | |
12 | +fi | |
13 | + | |
14 | +TMPF=/tmp/dupdel_$$ | |
15 | +TMPF2=/tmp/dupdel2_$$ | |
16 | +TMPF3=/tmp/dupdel3_$$ | |
17 | + | |
18 | +trap "rm -f $TMPF $TMPF2 $TMPF3; exit 1" 0 1 2 9 15 | |
19 | + | |
20 | +# all file list | |
21 | +ls -l | grep -v -e "^total" -e "^d" > $TMPF | |
22 | +# sort by size | |
23 | +cat $TMPF |awk '{print $5}' |sort -n > $TMPF2 | |
24 | +# sort by size and uniq | |
25 | +cat $TMPF |awk '{print $5}' |sort -n |uniq > $TMPF3 | |
26 | + | |
27 | +# 同じサイズのものを取り出す | |
28 | +#diff $TMPF2 $TMPF3 | |
29 | +LIST=`diff $TMPF2 $TMPF3| grep "<" |sed "s/^..//" |sort -u` | |
30 | +#echo "LIST=$LIST" | |
31 | + | |
32 | +for i in $LIST | |
33 | +do | |
34 | + # LIST2:同じサイズのファイル一覧 | |
35 | + LIST2=`grep " $i " $TMPF |awk '{print $9}'` | |
36 | + | |
37 | + if [ "$VF" = "2" ]; then | |
38 | + echo "LIST2=[$LIST2]" | |
39 | + fi | |
40 | + for i in $LIST2 | |
41 | + do | |
42 | + for j in $LIST2 | |
43 | + do | |
44 | + if [ -f $i -a -f $j ]; then | |
45 | + if [ "$i" != "$j" ]; then | |
46 | + if [ "$VF" = "1" ]; then | |
47 | + echo "check $i $j" | |
48 | + fi | |
49 | + cmp $i $j > /dev/null | |
50 | + if [ $? -eq 0 ]; then | |
51 | + echo "### same file $i $j, rm $j" | |
52 | + rm $j | |
53 | + fi | |
54 | + fi | |
55 | + fi | |
56 | + done | |
57 | + done | |
58 | +done | |
59 | + |
@@ -0,0 +1,13 @@ | ||
1 | +#!/bin/sh | |
2 | + | |
3 | +# for HI-UX/WE2 | |
4 | +#ERRNO_H=/usr/include/sys/errno.h | |
5 | + | |
6 | +# for Linux | |
7 | +#ERRNO_H=/usr/src/linux/include/asm/errno.h | |
8 | +#ERRNO_H=/usr/include/asm/errno.h | |
9 | +ERRNO_H="/usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h" | |
10 | + | |
11 | +echo "" | |
12 | +grep "#.*define.*[ ]${1}[ ][ ]*" $ERRNO_H |head -1 | |
13 | +echo "" |
@@ -0,0 +1,28 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# 小数点も計算する expr | |
4 | +# | |
5 | +# 1995/04/19 V1.00 by oga. | |
6 | +# 2010/08/14 V1.01 support -s | |
7 | +# by oga. | |
8 | +SCALE=5 | |
9 | + | |
10 | +if [ "$1" = "" -o "$1" = "-h" ]; then | |
11 | + echo "usage : expr2 [-s <scale($SCALE)>] <式> : <式>を小数点以下まで計算します" | |
12 | + echo " カッコを使用する場合<式>を\"\"で囲って下さい" | |
13 | + echo " 乗算は 'x' を使って下さい" | |
14 | + echo " (例) expr2 2x4/3" | |
15 | + echo " -s: 小数点以下精度(default:$SCALE)" | |
16 | + exit 1 | |
17 | +fi | |
18 | + | |
19 | +if [ "$1" = "-s" ]; then | |
20 | + SCALE=$2 | |
21 | + shift | |
22 | + shift | |
23 | +fi | |
24 | + | |
25 | +bc << EOF | |
26 | +scale=$SCALE | |
27 | +`echo $* |sed -e "s/x/\*/g" -e "s/,//g"` | |
28 | +EOF |
@@ -0,0 +1,15 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# Lib find from func name | |
4 | +# | |
5 | +# 00/10/23 by oga | |
6 | + | |
7 | +LIST=`ls *.a *.so *.sl 2>/dev/null` | |
8 | +for i in $LIST | |
9 | +do | |
10 | + echo "## $i" | |
11 | + nm $i |grep $* > /dev/null 2>&1 | |
12 | + if [ $? -eq 0 ]; then | |
13 | + nm $i |grep $* | |
14 | + fi | |
15 | +done |
@@ -0,0 +1,87 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# mkindex2 : dm の READMEからindex.htmlを作る | |
4 | +# | |
5 | +# 96/05/23 by oga. | |
6 | +# | |
7 | +# 注意:漢字名つきファイルはリンクできません | |
8 | + | |
9 | +INDEX=index.html | |
10 | + | |
11 | +echoline() | |
12 | +{ | |
13 | + echo -e "<A HREF=\c" >> $INDEX | |
14 | + echo -e '"\c' >> $INDEX | |
15 | + if [ -d $1 ]; then | |
16 | + echo -e "${1}/index.html\c" >> $INDEX | |
17 | + else | |
18 | + echo -e "${1}\c" >> $INDEX | |
19 | + fi | |
20 | + echo -e '"\c' >> $INDEX | |
21 | + if [ -d $1 ]; then | |
22 | + echo -e ">⇒${2}</A>\c" >> $INDEX | |
23 | + else | |
24 | + echo -e ">${2}</A>\c" >> $INDEX | |
25 | + fi | |
26 | + shift | |
27 | + shift | |
28 | + #echo "$*" >> $INDEX # 作成者 作成日 | |
29 | + echo "" >> $INDEX | |
30 | + return | |
31 | +} | |
32 | + | |
33 | +mkindex2() | |
34 | +{ | |
35 | + F=0 | |
36 | + FF=0 | |
37 | + echo "<title>`pwd`</title>" > $INDEX | |
38 | + | |
39 | + while read LINE | |
40 | + do | |
41 | + if [ "$LINE" = "" ]; then | |
42 | + continue | |
43 | + fi | |
44 | + if [ $F -eq 0 ]; then | |
45 | + if [ $FF -eq 0 ]; then | |
46 | + echo "<h1>$LINE</h1>" >> $INDEX | |
47 | + FF=1 | |
48 | + fi | |
49 | + else | |
50 | + echo -e " <LI>\c" >> $INDEX | |
51 | + echoline $LINE | |
52 | + # echoline `echo $LINE |awk '{print $1" "$2}'` | |
53 | + fi | |
54 | + echo $LINE |grep "\-\-\-\-" > /dev/null 2>&1 | |
55 | + if [ $? -eq 0 -a $F -eq 0 ]; then | |
56 | + F=1 | |
57 | + echo "<UL>" >> $INDEX | |
58 | + echo -e "<LI>\c" >> $INDEX | |
59 | + echoline ../index.html 前のディレクトリ | |
60 | + fi | |
61 | + done < README | |
62 | + echo "</UL>" >> $INDEX | |
63 | + | |
64 | + return | |
65 | +} | |
66 | + | |
67 | +# | |
68 | +# MAIN | |
69 | +# | |
70 | +if [ "$1" = "-h" ]; then | |
71 | + echo "usage : mkindex2 [-r]" | |
72 | + exit 1 | |
73 | +fi | |
74 | + | |
75 | +if [ "$1" = "-r" ]; then | |
76 | + PWD2=`pwd` | |
77 | + for j in `find . -type d -print` | |
78 | + do | |
79 | + echo "## Make index Ver2 dir=$j" | |
80 | + cd $PWD2 | |
81 | + cd $j | |
82 | + mkindex2 | |
83 | + done | |
84 | +else | |
85 | + mkindex2 | |
86 | +fi | |
87 | + |
@@ -0,0 +1,11 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# display ruler | |
4 | +# | |
5 | +# :r! ruler [x] | |
6 | + | |
7 | +if [ "$1" = "" ]; then | |
8 | + echo "----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8" | |
9 | +else | |
10 | + echo "----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----A----+----B----+----C----+----D----+----E----+----F" | |
11 | +fi |
@@ -0,0 +1,20 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# check spell | |
4 | +# | |
5 | + | |
6 | +TMP=/tmp/spell_tmp | |
7 | + | |
8 | +echo $* > $TMP | |
9 | + | |
10 | +#spell $TMP | |
11 | +ispell $TMP | |
12 | + | |
13 | +if [ -f $TMP.bak ]; then | |
14 | + echo "NG: `cat $TMP.bak`" | |
15 | + echo "OK: `cat $TMP`" | |
16 | +else | |
17 | + echo "[`cat $TMP`] spell OK!" | |
18 | +fi | |
19 | + | |
20 | +rm ${TMP}* |
@@ -0,0 +1,70 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# split2 : split & create merge script tool | |
4 | +# | |
5 | +# 2001/09/07 V1.00 by oga | |
6 | +# | |
7 | +if [ "$2" = "" ]; then | |
8 | + echo "usage : `basename $0` <filename> <size>{k|m}" | |
9 | + echo " ex.) `basename $0` xxxx.lzh 1m" | |
10 | + exit 1 | |
11 | +fi | |
12 | + | |
13 | +NAME=$1 | |
14 | +SEP_SIZE=$2 | |
15 | +DIR=split_dat | |
16 | +PREFIX=spdat | |
17 | + | |
18 | +if [ -d $DIR ]; then | |
19 | + echo "delete $DIR/${PREFIX}* OK? [no:^C]" | |
20 | + read X | |
21 | + rm $DIR/${PREFIX}* | |
22 | +else | |
23 | + mkdir -p $DIR | |
24 | +fi | |
25 | + | |
26 | +split -b $SEP_SIZE --verbose $NAME $DIR/${PREFIX}_ | |
27 | +if [ $? -ne 0 ]; then | |
28 | + echo "Error: split failed." | |
29 | + exit 1; | |
30 | +fi | |
31 | + | |
32 | +cd $DIR | |
33 | + | |
34 | +FIRST=1 | |
35 | +echo "@echo off" > $PREFIX.bat0 | |
36 | +echo "REM create by split2 (C)oga." >> $PREFIX.bat0 | |
37 | +echo "IF EXIST "$NAME" GOTO ERROR" >> $PREFIX.bat0 | |
38 | +for i in `ls ${PREFIX}_*` | |
39 | +do | |
40 | + if [ $FIRST -eq 1 ]; then | |
41 | + FIRST=0 | |
42 | + echo "copy /B \"$i\" \"$NAME\"" >> $PREFIX.bat0 | |
43 | + else | |
44 | + echo "copy /B \"$NAME\"+\"$i\" \"$NAME\"" >> $PREFIX.bat0 | |
45 | + fi | |
46 | +done | |
47 | +echo "GOTO END" >> $PREFIX.bat0 | |
48 | +echo ":ERROR" >> $PREFIX.bat0 | |
49 | +echo "ECHO ##### Error: $NAME already exist. #####" >> $PREFIX.bat0 | |
50 | +echo "PAUSE" >> $PREFIX.bat0 | |
51 | +echo "exit" >> $PREFIX.bat0 | |
52 | +echo ":END" >> $PREFIX.bat0 | |
53 | +echo "ECHO ##### create $NAME done. #####" >> $PREFIX.bat0 | |
54 | +echo "PAUSE" >> $PREFIX.bat0 | |
55 | + | |
56 | +sed "s/$/ /" $PREFIX.bat0 > $PREFIX.bat | |
57 | +rm -f $PREFIX.bat0 | |
58 | + | |
59 | +cat > $PREFIX.sh << EOF | |
60 | +#!/bin/sh | |
61 | +# create by split2 (C)oga. | |
62 | +if [ -f '$NAME' ]; then | |
63 | + echo '##### Error: $NAME already exist. #####' | |
64 | + exit 1 | |
65 | +fi | |
66 | +cat ${PREFIX}_* >> '$NAME' | |
67 | +echo '##### create $NAME done. #####' | |
68 | +EOF | |
69 | + | |
70 | + |
@@ -0,0 +1,20 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# suffix change e.g. .JPG => .jpg | |
4 | +# | |
5 | +# 2000/10/10 by oga | |
6 | +# | |
7 | + | |
8 | +if [ "$2" = "" -o "$1" = "-h" ]; then | |
9 | + echo "usage: sufchg <old_suffix> <new_suffix>" | |
10 | +fi | |
11 | + | |
12 | +OLDSUF=$1 | |
13 | +NEWSUF=$2 | |
14 | + | |
15 | +for i in `ls *.$1` | |
16 | +do | |
17 | + NEWNM=`echo $i |sed "s@\.$OLDSUF@\.$NEWSUF@"` | |
18 | + echo "mv $i => $NEWNM" | |
19 | + mv $i $NEWNM | |
20 | +done |
@@ -0,0 +1,35 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# telx : search telephone number system (w | |
4 | +# | |
5 | +# | |
6 | +if [ -z "$1" ] ; then | |
7 | + echo "usage : telx {[key] | -e}" | |
8 | + echo "" | |
9 | + echo " -e : edit tel data" | |
10 | + echo "" | |
11 | + echo "ex) telx asahi" | |
12 | + exit 1 | |
13 | +fi | |
14 | +if [ "`uname`" = "HI-UX" ]; then | |
15 | + TELDAT=/users/oga/doc/tel_data | |
16 | +else | |
17 | + TELDAT=$HOME/doc/tel_data | |
18 | +fi | |
19 | + | |
20 | +if [ "$1" = "-e" ]; then | |
21 | + vi $TELDAT | |
22 | + echo "Edit end." | |
23 | + exit 0 | |
24 | +fi | |
25 | + | |
26 | +echo "" | |
27 | +grep -q $1 $TELDAT | |
28 | +if [ $? -ne 0 ]; then | |
29 | + echo "$1 not registerd." | |
30 | +else | |
31 | + grep $1 $TELDAT | |
32 | +fi | |
33 | +echo "" | |
34 | + | |
35 | + |
@@ -0,0 +1,9 @@ | ||
1 | +#!/bin/sh | |
2 | +(cd ${1-.};pwd) | |
3 | +find ${1-.} -type d |sort -f | sed -e "s,^${1-.},," -e "/^$/d" -e \ | |
4 | + "s,[^/]*/\([^/]*\)$,\+--\1," -e \ | |
5 | + "s,[^/]*/,| ,g" | |
6 | + | |
7 | +#find ${1-.} -type d |sort -f | sed -e "s,^${1-.},," -e "/^$/d" -e \ | |
8 | +# "s,[^/]*/\([^/]*\)$,\`--\1," -e \ | |
9 | +# "s,[^/]*/,| ,g" |
@@ -0,0 +1,30 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# UNIXFILE to DOSFILE(UNIXFILE.txt) auto generate | |
4 | +# | |
5 | +# 2001/09/05 V1.01 -rep support by oga. | |
6 | +# | |
7 | + | |
8 | +TMPF=/tmp/tmp_u2dos2_$$ | |
9 | + | |
10 | +if [ "$1" = "" -o "$1" = "-h" ]; then | |
11 | + echo "usage: u2dos2 [-rep] <file> ..." | |
12 | + exit 1 | |
13 | +fi | |
14 | + | |
15 | +if [ "$1" = "-rep" ]; then | |
16 | + REP=1 | |
17 | + shift | |
18 | +fi | |
19 | + | |
20 | +for i in $* | |
21 | +do | |
22 | + if [ "$REP" = "1" ]; then | |
23 | + echo "convert and replace $i (replace)" | |
24 | + u2dos $i > $TMPF | |
25 | + mv $TMPF $i | |
26 | + else | |
27 | + echo "convert to $i.txt ..." | |
28 | + u2dos $i > $i.txt | |
29 | + fi | |
30 | +done |
@@ -0,0 +1,11 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# vif : カレントディレクト以下からファイルを探し出して | |
4 | +# 開く | |
5 | +# | |
6 | +if [ "$1" = "" ]; then | |
7 | + echo "usage : $0 <filename>" | |
8 | + exit 1 | |
9 | +fi | |
10 | + | |
11 | +vi `find . -name "$1"` |
@@ -0,0 +1,20 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# vig <keyword> : 引数を含むファイルをviする。 | |
4 | +# | |
5 | +# 1995/03/27 by oga | |
6 | +# 2000/05/08 support -r | |
7 | +# | |
8 | + | |
9 | +if [ "$1" = "-h" -o "$1" = "" ]; then | |
10 | + echo "usage: vig [-r] <search_key>" | |
11 | + exit 1 | |
12 | +fi | |
13 | + | |
14 | +if [ "$1" = "-r" ]; then | |
15 | + shift | |
16 | + LIST=`find . -type f` | |
17 | + vim +/$1/ `grep $1 $LIST |awk -F: '{ print $1}' |sort -u ` | |
18 | +else | |
19 | + vim +/$1/ `grep $1 * |awk -F: '{ print $1}' |sort -u ` | |
20 | +fi |
@@ -0,0 +1,53 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# vvi : ファイル選択画面つきvi (その他のコマンドも可能) | |
4 | +# | |
5 | +# usage : vvi [ 実行コマンド [引数1, 引数2, ...] ] | |
6 | +# | |
7 | +# 実行コマンド : ファイル選択後実行するコマンド(default : "vi") | |
8 | +# 引数n : 実行コマンドの引数 | |
9 | +# コマンド <file> 引数1, 引数2, ... が実行される | |
10 | +# (例) vvi less ... ファイル選択後lessを実行する。 | |
11 | +# | |
12 | +# 1995.05.15 'v'コマンドサポート | |
13 | +# 1996.02.24 port to Linux | |
14 | + | |
15 | +#echo "`date` `hostname` `id -u -n`" >> /users/OSF_DCE/oga/tmp/log_vvi | |
16 | + | |
17 | +X=0 | |
18 | +Y=0 | |
19 | +OFF_Y=0 | |
20 | +CODE=0 | |
21 | +while [ "$CODE" = "0" ] | |
22 | +do | |
23 | + if [ "$Target" = "H3050" ] ; then | |
24 | + /users/bin/3050/filer $X $Y $OFF_Y 2> /tmp/vvi$$ | |
25 | + else | |
26 | + #/users/OSF_DCE/oga/bin/filer $X $Y $OFF_Y 2> /tmp/vvi$$ | |
27 | + $HOME/bin/filer $X $Y $OFF_Y 2> /tmp/vvi$$ | |
28 | + fi | |
29 | + CODE="$?" | |
30 | + FILE_NAME=`cat /tmp/vvi$$ | awk '{ print $1 }'` | |
31 | + X=`cat /tmp/vvi$$ | awk '{ print $2 }'` | |
32 | + Y=`cat /tmp/vvi$$ | awk '{ print $3 }'` | |
33 | + PWD=`cat /tmp/vvi$$ | awk '{ print $4 }'` | |
34 | + OFF_Y=`cat /tmp/vvi$$ | awk '{ print $5 }'` | |
35 | + DEL_F=`cat /tmp/vvi$$ | awk '{ print $6 }'` | |
36 | + VI_F=`cat /tmp/vvi$$ | awk '{ print $7 }'` | |
37 | + cd $PWD | |
38 | + if [ "$CODE" = "0" ] ; then | |
39 | + if [ "$DEL_F" = "1" ]; then | |
40 | + stty echo | |
41 | + echo "\033[7mDELETE\033[0m \c" | |
42 | + rm -i $FILE_NAME | |
43 | + else | |
44 | + if [ "$1" = "" -o "$VI_F" = "1" ] ; then | |
45 | + vi $FILE_NAME | |
46 | + else | |
47 | + $1 $FILE_NAME $2 $3 $4 $5 $6 $7 $8 $9 | |
48 | + fi | |
49 | + fi | |
50 | + fi | |
51 | +done | |
52 | +clear | |
53 | +rm /tmp/vvi$$ |
@@ -0,0 +1,56 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# winerr : Windowsエラー番号の解析 | |
4 | +# | |
5 | +# V1.01 2001/01/12 add /kita1/documents/memo/xw.winerr search by oga | |
6 | +# V1.02 2008/12/31 support DirectX Error | |
7 | +# | |
8 | +#INCLUDE=/kita1/win/include | |
9 | +#INCLUDE=/hda6/home/oga/win/include | |
10 | +INCLUDE=/home/oga/win/include | |
11 | + | |
12 | +ERRNO=$INCLUDE/errno.h | |
13 | +WINERR=$INCLUDE/winerror.h | |
14 | +SOCKERR=$INCLUDE/winsock.h | |
15 | +LMERR=$INCLUDE/lmerr.h | |
16 | +DXERR=$INCLUDE/vfwmsgs.h | |
17 | + | |
18 | +WINERRLIST=/kita1/documents/memo/xw.winerr | |
19 | + | |
20 | +if [ "$1" = "" ]; then | |
21 | + echo "usage : `basename $0` [-dx] <err_code>" | |
22 | + exit 1 | |
23 | +fi | |
24 | + | |
25 | +DXF=0 | |
26 | +if [ "$1" = "-dx" ]; then | |
27 | + DXF=1 | |
28 | + shift | |
29 | +fi | |
30 | + | |
31 | +if [ "$DXF" = "1" ]; then | |
32 | + grep -q $1 $DXERR | |
33 | + if [ $? -eq 0 ]; then | |
34 | + echo "■ DirectX Error($1)" | |
35 | + grep -B2 "define.*HRESULT.*$1" $DXERR | |
36 | + fi | |
37 | + exit; | |
38 | +fi | |
39 | + | |
40 | +if [ $1 -gt 9999 ]; then | |
41 | + ERR=`expr $1 - 10000` | |
42 | + echo "■ socket error ($1)" | |
43 | + grep "\+$ERR" $SOCKERR | |
44 | +elif [ $1 -gt 2099 ]; then | |
45 | + ERR=`expr $1 - 2100` | |
46 | + echo "■ LanManager error ($1)" | |
47 | + grep "define.*\+$ERR)" $LMERR | |
48 | + #grep -e "^$1," -e ",$1," $WINERRLIST | |
49 | +else | |
50 | + echo "■ errno($1)" | |
51 | + grep "define.*[ ][ ]*$1 " $ERRNO | |
52 | + echo "■ GetLastError($1)" | |
53 | + grep "define.*[ ][ ]*${1}L" $WINERR | |
54 | + #grep -e "^$1," -e ",$1," $WINERRLIST | |
55 | +fi | |
56 | + |
@@ -0,0 +1,24 @@ | ||
1 | +#!/bin/sh | |
2 | +# | |
3 | +# カレントディレクトリにあるWindowsの.libから関数を探す | |
4 | +# | |
5 | +# *.libをコピーしたディレクトリで、winlibsrch <func_name> を実行する | |
6 | +# | |
7 | + | |
8 | +if [ "$1" = "" -o "$1" = "-h" ]; then | |
9 | + echo "usage: $0 <func_name>" | |
10 | + exit 1 | |
11 | +fi | |
12 | +KEY=$1 | |
13 | + | |
14 | +cd /users/oga/win/lib | |
15 | + | |
16 | +#for i in `ls` | |
17 | +for i in `find . -type f` | |
18 | +do | |
19 | + strings $i |grep -q $KEY | |
20 | + if [ $? -eq 0 ]; then | |
21 | + echo "■ $KEY found in $i " | |
22 | + strings $i |grep $KEY | |
23 | + fi | |
24 | +done |