fix _make_git_tar_dir.sh - don't 'append directory' to symlinks
[cmdllinux.git] / scripts / _insertline.sh
blobfcf33d074cc8fd6385f0da6af1f4937d170d744d
1 [ -z "$1" ] && exit 1
2 FILE="$3"
3 PATT="$1"
4 LINE="$2"
5 insertline()
7 NUM1=`grep -n "$1" "$3" | cut -d : -f 1 | head -n 1`
8 NUM2=`wc -l "$3" | cut -d " " -f 1`
9 sed -n 1,${NUM1}p "$3"
10 NUM1=`expr $NUM1 + 1`
11 echo "$2"
12 sed -n ${NUM1},${NUM2}p "$3"
15 insertline "$PATT" "$LINE" "$FILE"
17 #sed '/pattern/a"line to insert"' file.txt