gpt4 book ai didi

linux - 使用awk查找字母并打印结果

转载 作者:太空宇宙 更新时间:2023-11-04 06:06:53 25 4
gpt4 key购买 nike

我有一个 Student.txt 文件,其中包含一些列(姓名、c1、c2、c3、c4),如下所示

Jack Poki theo 100 49 38
.

像上面这样的15个注册表,我想用awk找到名字以J或M开头的学生,并仅打印他们的姓氏和名字

最佳答案

我认为您正在寻找这个:

awk '/^[JM]/{print $1,$2}' i_ve_got_an_vi_edirtor_with_some_collums.file

更新

Now i need the same but only for students that the surname starts from [A-D]

awk '$2~/^[A-D]/{print $1,$2}' i_ve_got_an_vi_edirtor_with_some_collums.file

关于linux - 使用awk查找字母并打印结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34858474/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com