repo.or.cz
/
cmdllinux.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
fix _make_git_tar_dir.sh - don't 'append directory' to symlinks
[cmdllinux.git]
/
scripts
/
_insertline.sh
blob
fcf33d074cc8fd6385f0da6af1f4937d170d744d
1
[
-z
"
$1
"
] &&
exit
1
2
FILE
=
"
$3
"
3
PATT
=
"
$1
"
4
LINE
=
"
$2
"
5
insertline
()
6
{
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
"
13
}
14
15
insertline
"
$PATT
"
"
$LINE
"
"
$FILE
"
16
17
#sed '/pattern/a"line to insert"' file.txt