Hi I'm a Linux noob and I'd to know how to replace a line starting with "/" with tag.
Here's an example:
/Foo is awesome
and I would like to get
<i>Foo is awesome</i>
I would appreciate any help!
You could use awk with substr
like this:
awk '/^\//{$0 = "<i>" substr($0,2) "</i>"}1' file
When there is a /
at the start of the line, append the tags and use substr
to remove the slash from the original line. 1
is true
so awk does the default action for each line, which is to print the line.