Given file.txt that looks like this:
line_ some text
line_ some text
line_ some text
How can I number the lines like this with Bash:
line_1 some text
line_2 some text
line_3 some text
Here is my idea so far, but it doesn't work:
#!/bin/bash
var = 1
cat ./file.txt
while read line; do
sed "s/line_/line_(( var++ ))/"
done < ./file.txt