If I have a text file saying this:
Xgrep () { something ; }
Xgrep
Xgrep
Xgrep
Xgrep
Xgrep
I want it to look like this
Xgrep () { something ; }
Xgrep 12
Xgrep 13
Xgrep 14
Xgrep 15
Xgrep 16
Meaning I want to choose at which number to begin, with suffixes instead of prefixes with one space between (-s " " for a space between). I thought that I could use nl for this, but reading the man page it doesn't seem so. I tried this:
nl -b pexpr=Xgrep -s " " ~/desktop/test.txt
However this just out put this:
Xgrep
Xgrep
Xgrep
Xgrep
Xgrep
Which is probably because the regex syntax is wrong but I couldn't find a way for it to match, all other ways it just listed the usage.
This website is pretty much exactly what I am trying to do, but in command line form and only with numbers suffix.
nl -b p'^Xgrep$' fileornl --body-numbering=p'^Xgrep$' fileI think. However, I don't know thatnlallows either RH placement (as opposed to right justification) or provision of a specific start index. If you aren't stuck onnlyou could use something likeawk -vi=12 '/^Xgrep$/ {$(NF+1)=i++}1' file