test.txt文件中的内容:
mtd1 008000 000100 nandflash
mtd2 008040 001000 norflash
mtd3 008000 001000 root
mtd4 004000 001000 httcfs
获取包含mtd2数据的第二个数据
命令:grep "mtd2" ./test.txt | cut -d " " -f 2
结果:008040
cut命令:
cut -d 指定分隔符
cut -d " " -f 2-4 ./test.txt 指定分隔符为空格,显示第2到4列
cut -c 1,4 ./test.txt ##显示第一和第四个字符