Issue
I have this two commands with sed, but I want to create a script (a .sed file) with these two commands...
I don't know how to create a sed script. Any help, please?
sed -E 's/(;[0-9]+)\.([0-9])(;[^;]*;[^;]*)$/\1.\20\3/' \ -E 's/(;[0-9]+)\.([0-9]{2})[0-9]+(;[^;]*;[^;]*)$/\1.\2\3/'
Solution
Add the code to a file:
script.sed
s/(;[0-9]+)\.([0-9])(;[^;]*;[^;]*)$/\1.\20\3/
s/(;[0-9]+)\.([0-9]{2})[0-9]+(;[^;]*;[^;]*)$/\1.\2\3/
Run it with the correct parameteres:
sed -Ef script.sed
Or with shebang (#!
):
script2.sed
#!/bin/sed -Ef
s/(;[0-9]+)\.([0-9])(;[^;]*;[^;]*)$/\1.\20\3/
s/(;[0-9]+)\.([0-9]{2})[0-9]+(;[^;]*;[^;]*)$/\1.\2\3/
Run it like this:
chmod u+x script2.sed
./script2.sed
Answered By - Thor