Home using sed with variables in CSH
 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. Example: 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: #!/bin/csh -f set filename=/export/home/develop/data/buy_load_file.dat set line=1 set sak_num=1 set search=SAK set totallines=wc -l $filename | cut -f1 -d' ' echo$totallines while( $line <=$totallines ) sed "$line s/$search/$sak_num/"$filename @ line++ @ sak_num++ end  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. Thanks!