hopefully this makes sense. My ideal goal is to read a file and change a variable with another variable, but the new variable is incremented each time.
input file -
SAK, 123, 345
SAK, 456, 789
SAK, 789, 901
What I want my output to look like -
1, 123, 345
2, 456, 789
3, 789, 901
As you can see SAK is being replaced with a number, but the number is incremented every time.
I tried doing this:
set totallines=`wc -l $filename | cut -f1 -d' '`
while( $line <= $totallines )
`sed "$line s/$search/$sak_num/" $filename`
But the sed command never works for me. I tried reading different ways to do it, but I think my issue is with $filename that it's not able to read it properly. I think awk could be another command that could possibly do what I want it to do, but not sure how.
Any ideas? Or maybe an easier way for me to get the output I desire.