In troubleshooting a reboot crash I need to print every line in a file to an output console. What I want to do is run a linux command line or script to take each line in a file, and put a print statement after it containing the line, so for example:
while x<100
x=x+1
end while
would become
while x<100
print "while x<100"
x=x+1
print "x=x+1"
end while
print "end while"
even better would be if the print statements could include the line number:
while x<100
print "Line 50: while x<100"
x=x+1
print "Line 52:x=x+1"
end while
print "Line 54: end while"
The idea here is to find the last line in the script that executes as that will be the line that probably caused the device to reboot. Currently I do this manually, and it is rather time consuming to add all those lines.
I'm aware of the existence of SED and AWK but have never used them, I do use ex/vi/grep/ls/wc fairly often to sort things out in text files though and have experience with basic shell scripting.
EDIT: Note that none of the code in my question is a shell script. I'm looking for help with creating a shell script or a command line to process a file so that each line in the file is followed by a print statement containing the previous line.