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