如何在 shell 中剪切字符串的第一列(可变长度)?
字符串前:
23006 帮助.txt
我需要 23006 作为输出
很多种方法:
cut -d' ' -f1 <filename # If field separator is space
cut -f1 <filename # If field separator is tab
cut -d' ' -f1 <filename | cut -f1 # If field separator is space OR tab
awk '{print $1}' filename
while read x _ ; do echo $x ; done < filename
cut -d " " -f1 test.txt
其中 test.txt 包含您的输入行
这个对我有用
cut -d' ' -f2-