I want to create a shell script that will give me the output below. I want to insert the numbers from the input file to my url addresses below. And from the numbers below, I want to separate the last digit with a period (i.e. from 222222222222 to 22222222222.2). Appreciate any help.
---------- Post updated at 03:57 PM ---------- Previous update was at 03:10 PM ----------
Hi Guru,
Thank you very much for this elegant script. I just want to add more strings on the output file. I want to insert #!/bin/bash on top of the output file.
The dot in replacement text is not special. You do not need to backslash-escape it in that context. Backslash-escaping non-special characters yields undefined sequences which can cause problems with some implementations (and opens the door to the remote possibility that a future extension to the standard will break current sed scripts).
The insert (i) command should be followed by backslash and newline, before the text to insert. (GNU sed supports text immediately after the command name but this is not portable.)
In a strictly compliant implementation, the \n escape sequence is only allowed in a regular expression evaluated against the pattern space. It is not allowed in replacement text nor in addresses. As with the \. sequence mentioned above, \n in in those contexts yields an undefined sequence (GNU sed will probably emit a newline). However, within the text argument to the insert (i) and append (a) commands, backslashes are stripped and the following character treated literally. \! becomes ! and \n becomes n (GNU sed instead chooses to emit a newline).
GNU sed developers may call these extensions, but they're more like incompatible deviations. Just a little one-liner and look at all the potential gotchas. What a headache!