Hello,
I want to read a file line by line and every time i find a sting that starts with:
"USER PID PPID %CPU %MEM STARTED TIME VSZ RSS COMMAND"
add a sequential number.
i.e.
"1 USER PID PPID %CPU %MEM STARTED TIME VSZ RSS COMMAND"
"2 USER PID PPID %CPU %MEM STARTED TIME VSZ RSS COMMAND"
"3 USER PID PPID %CPU %MEM STARTED TIME VSZ RSS COMMAND"......
the output should be on a second file (ft_tmp.log)
I did:
i=1
add=$i
while read line;
do
`sed -n /USER/,/COMMAND/p | sed "s/^/$add /g" > ft_tmp.log`
let add=add+1
let i=i+1
done
but all the lines get the same value (1)...
HELP......