I have a file called xx with the env redirected into it 5 times:
env >> xx
env >> xx
env >> xx
env >> xx
env >> xx
I have to read an input file (here: xx) and look for occurrences of the current user who is executing this script. Once finding an occurrence of the username I have to take that line and append it to a file and display a line number and a bracket against the saved line. The file should look lie that:
1) PWD=...
2) USER=...
3) MAIL=...
4) LOGNAME=...
5) HOME=...
6) PWD=...
7) USER=...
8) MAIL=...
9) LOGNAME=l...
10) HOME=...
I can not use temporary file, sed, awk...
Can somebody help me
So far I' ve got something like this:
echo "Give the name of the file: "
read fileName
egrep -w "PWD" $fileName | cat -b >> $fileName
egrep -w "USER" $fileName | cat -b >> $fileName
egrep -w "MAIL" $fileName | cat -b >> $fileName
egrep -w "LOGNAME" $fileName | cat -b >> $fileName
egrep -w "HOME" $fileName | cat -b >> $fileName