perl - Trim trailing and leading spaces in a file fields separated by delimiter using unix command -



perl - Trim trailing and leading spaces in a file fields separated by delimiter using unix command -

input file:

abc | hello |123 | def | hi ram | 456 |

output file should follows

abc|hello|123| def|hi ram|456

please allow me know if can accomplish using awk or sed commands. want execute same in perl using scheme command

perl -lpe 's/ \s*[|]\s* /|/xg' file

output

abc|hello|123| def|hi ram|456|

perl unix awk sed

Comments