2016年9月29日木曜日

bash RANDOM

0〜30s.

while true ;do date; toDoSomething;RND=`expr $RANDOM % 30`;echo $RND;sleep $RND;done

bash RANDOM

0〜30s.

while true ;do date; toDoSomething;RND=`expr $RANDOM % 30`;echo $RND;sleep $RND;done

bash 拡張子を変更しつつcopy


$ for i in *.jpg; do cp $i ${i%.jpg}.jpg_uptodate; done

$ for i in *.mp4; do cp $i ${i%.mp4}.mp4_uptodate; done

2016年8月16日火曜日

bash 引数 check

#!/bin/bash

set -eu



if [ $# -ne 1 ]; then
  echo "指定された引数は$#個です。" 1>&2
  echo "実行するには3個の引数が必要です。" 1>&2
  exit 1
fi

2016年8月9日火曜日

sed

[上書き保存]
o Original File保存 -i.org
o 文字列を置換 -e "s/oldstrings/newstrings/"
o File上書き -i

sed -i.org -e "s/ pi --noclear/ PIPI --noclear/" /etc/systemd/system/getty.target.wants/getty@tty1.service



[commnet行削除]
$ sed -e '/^#/d' sample.txt
 
[commnet記号削除] 
$ sed -e 's/^#//' sample.txt

 

2016年7月29日金曜日

連続file作成


bash

$ touch sample_{0..100}.txt


timestamp 2016.08.01 12:59
$ touch -t 2016008011259 sample_{0..100}.txt

2016年6月1日水曜日

tree Command

-N : 日本語File名表示
-C : Color表示