I have the following command cat urls.txt | sed 's/com/com\//'
which will add a slash in the last of url but the problem is whenever if there are other tlds like net
and org
it won't work, how I can make it to add the slash without specifying the tld
Tried to add a slash in url without to without specifying the tld
CodePudding user response:
$
means "end of line" in sed regexes. Therefore,
sed 's=$=/='
will add a slash to each line's end.
Note that it uses a different delimiter than /
to prevent the need of a backslash which improves readability.