added string search
This commit is contained in:
parent
91bfd4eea4
commit
bda7e9eace
14
en
14
en
@ -22,11 +22,12 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
help="$(printf "Commands:\n\
|
help="$(printf "Commands:\n\
|
||||||
|
/ – display lines containing a string.\n\
|
||||||
|
? – displays this help message.\n\
|
||||||
a – appends a line to the current buffer.\n\
|
a – appends a line to the current buffer.\n\
|
||||||
c – clears the screen.\n\
|
c – clears the screen.\n\
|
||||||
d – deletes a line.\n\
|
d – deletes a line.\n\
|
||||||
e – evaluates a command in the shell environment.\n\
|
e – evaluates a command in the shell environment.\n\
|
||||||
? – displays this help message.\n\
|
|
||||||
i – inserts a line into the buffer at position line.\n\
|
i – inserts a line into the buffer at position line.\n\
|
||||||
p – prints the current buffer.\n\
|
p – prints the current buffer.\n\
|
||||||
q – terminates editing.\n\
|
q – terminates editing.\n\
|
||||||
@ -56,6 +57,13 @@ while test -n "$1"; do
|
|||||||
read -r command args
|
read -r command args
|
||||||
|
|
||||||
case $command in
|
case $command in
|
||||||
|
"/")
|
||||||
|
if test -z "$args"; then
|
||||||
|
printf "%s: %s: Missing argument.\n" "$argv0" "$args"
|
||||||
|
else
|
||||||
|
printf "%s" "$content" | nl | sed -n "/$args/p"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
"?")
|
"?")
|
||||||
if test -z "$args"; then
|
if test -z "$args"; then
|
||||||
printf "%s: %s\n" "$argv0" "$help"
|
printf "%s: %s\n" "$argv0" "$help"
|
||||||
@ -79,8 +87,6 @@ while test -n "$1"; do
|
|||||||
do
|
do
|
||||||
content="$(printf "%s\n" "$content" |\
|
content="$(printf "%s\n" "$content" |\
|
||||||
awk -v l="$line" 'NR == l {next} {print}')"
|
awk -v l="$line" 'NR == l {next} {print}')"
|
||||||
#del="$(printf "%s\n" "$content" | head -n "$line" | tail -n 1)"
|
|
||||||
#content="$(printf "%s\n" "$content" | sed -n "/$del/!p")"
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@ -111,7 +117,7 @@ while test -n "$1"; do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"r")
|
"r")
|
||||||
content="$(printf "%s" "$content" | sed "$args")"
|
content="$(printf "%s" "$content" | sed -e "$args")"
|
||||||
;;
|
;;
|
||||||
"w")
|
"w")
|
||||||
printf "%s\n" "$content" > "$1"
|
printf "%s\n" "$content" > "$1"
|
||||||
|
Loading…
Reference in New Issue
Block a user