added string search

This commit is contained in:
Emma Tebibyte 2023-07-13 15:58:19 -06:00
parent 91bfd4eea4
commit bda7e9eace

14
en
View File

@ -22,11 +22,12 @@ then
fi
help="$(printf "Commands:\n\
/ display lines containing a string.\n\
? displays this help message.\n\
a appends a line to the current buffer.\n\
c clears the screen.\n\
d deletes a line.\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\
p prints the current buffer.\n\
q terminates editing.\n\
@ -56,6 +57,13 @@ while test -n "$1"; do
read -r command args
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
printf "%s: %s\n" "$argv0" "$help"
@ -79,8 +87,6 @@ while test -n "$1"; do
do
content="$(printf "%s\n" "$content" |\
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
fi
;;
@ -111,7 +117,7 @@ while test -n "$1"; do
fi
;;
"r")
content="$(printf "%s" "$content" | sed "$args")"
content="$(printf "%s" "$content" | sed -e "$args")"
;;
"w")
printf "%s\n" "$content" > "$1"