Sample Header Ad - 728x90

nl add numbers suffix if regex match?

0 votes
1 answer
267 views
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.
Asked by DisplayName (12016 rep)
Oct 3, 2015, 03:55 PM
Last activity: Oct 3, 2015, 04:12 PM