8

Append variable texts to the beginning of each line in all files in a directory

view full story
linux-howto

http://www.unix.com – I am writing a code to append some numbers in the beginning of each line in all the files present in a directory. The number of files are really huge. The files are numbered as 1.sco, 2.sco, 4.sco (Note: 3.sco is missing). The files currently look like this: 1.sco Code: 2 3 5 6 6 7 My task is to open each 1.sco, 2.sco and so on and add a number based on its file name at the beginning of each line in all files. This is what I intend, sample output: 1.sco Code: 1 2 3 1 5 6 1 6 7 2.sco Code: 2 2 3 2 1 5 2 6 7 2 3 5 2 7 8 I have written a code but not getting where actually the (HowTos)