I would like to make a script, which allows user to input some text and it will output the same text with number of lines.Example:Input:Hi Jack,how are you?Output:0001: Hi Jack,0002: how are you?
Script - numberlines
scripting
A simple solution with read:I=0; while read -r; do ((I++)); echo $I: $REPLY; done< test.txt;where you can change test.txt to your script argument.If you don't want to use bash variable REPLY:I=0; while read -r LINE; do ((I++)); echo $I: $LINE; done< test.txt;or something else instead of 'LINE'