这不是 another question 的重复项。 之前在 stackoverflow 上发布的所有问题/解决方案都有相同的问题:额外的空格被替换为单个空格。
示例(1.txt)
filename Nospaces
filename One space
filename Two spaces
filename Three spaces
结果:
awk '{$1="";$0=$0;$1=$1}1' 1.txt
One space
Two spaces
Three spaces
awk '{$1=""; print substr($0,2)}' 1.txt
One space
Two spaces
Three spaces
最佳答案
使用 -F
选项指定 IFS
以避免 awk
省略多个空格
awk -F "[ ]" '{$1="";$0=$0;$1=$1}1' 1.txt
awk -F "[ ]" '{$1=""; print substr($0,2)}' 1.txt
关于linux - 使用 awk 或 sed 打印从第 n 到最后的所有列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36307566/