如何在shell中剪切字符串的第一列(可变长度)?
字符串的前缀:
23006 help.txt
我需要23006作为输出
发布于 2012-12-27 16:59:04
有多种方式:
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发布于 2012-12-27 17:00:25
cut -d " " -f1 test.txt其中test.txt包含您的输入行
发布于 2018-10-31 16:19:47
这件很适合我
cut -d' ' -f2-https://stackoverflow.com/questions/14051902
复制相似问题