How do I find all the occurance of a particular text in a file with a shell script. (Not using grep command)
CodePudding user response:
awk '/^admin/ {print NR;}' /etc/passwd
CodePudding user response:
A POSIX shell-only solution could be
n=0
while n=$((n 1)); IFS=':' read -r u _
do
case "$u" in
admin*) echo $n;;
esac
done < /etc/passwd