Posts Tagged: sed


28
Jun 11

Fix a single space in a URI

Looking for a regex to fix a file with a space appearing in random places in the URI:

sed -e 's/\(<[^ >]*\) \([^ ]*> [<.]\)/\1_\2/' < file.nt > newfile.nt

An improvement would be to change that to include more than one space… So here is my test command where I look for a token in the output to see what is matching:

sed -e 's/\(<[^ >]*\) \{1,\}\([^ ]\{0,\}> [<.]\)/\1FOUND\2/' < file.nt | grep FOUND