我有一个管道分隔文件如下
1 |Mike | 2000| 2|
2 |Peter | 4000| 2|
Run Code Online (Sandbox Code Playgroud)
..... ... .... 等等.
我想删除字段之间的前导和尾随空格.它应该如下所示
1|Mike|2000|2|
2|Peter|4000|2|
Run Code Online (Sandbox Code Playgroud)
shell脚本中有没有办法实现这个输出?
谢谢,Chandraa
你可以试试
cat datafile | tr -d ' \t'
cat datafile | tr -d '[:space:]' # will remove all spaces including the new line at the end of each line
Run Code Online (Sandbox Code Playgroud)