Can anybody helpme in understanding the follwoing command:
pr chap2 | sed "s/Page *[0-9]*$/(&)/" | enq
Can anybody helpme in understanding the follwoing command:
pr chap2 | sed "s/Page *[0-9]*$/(&)/" | enq
pr is a printing/paging tool. At a guess, it's adding page numbers to the file 'chap2'.
The sed part will add brackets around all instances of "Page #" (where # is an any digit number) that are on the end of a line. It should probably have '^ *' before the word 'Page' to prevent it messing with any line that ends with the word 'Page'.
Not seen enq before but I am guessing it enqueues a job to a printer queue.
The sed command converts 'Page N' at the end of a line to 'Page (N)'
A breakdown of the sed part:
s/<stuff>/<other stuff>/ Replaces the first occurrence of <stuff> on each line with <other stuff>
Page * Matches a string that contains 'Page' followed by any number (including zero) spaces.
[0-9]* Matches zero or more digits
$ Matches the end of the line
(&) Replace with the previously matched expression surround by brackets (ie add brackets)
Thank you Dragon
I just took this command from the manual pages for sed in AIX. I wanted to know the use of *$ after the [0-9] in this command, which would increase myunderstanding in sed command.
You are most welcome!
$ and ^ are highly useful characters when matching patterns.
Thank you johnson. But when I tried Im getting the following output like:
(Page N)