Skip to content

Instantly share code, notes, and snippets.

@bxb100
Last active January 29, 2023 09:01
Show Gist options
  • Save bxb100/d31eb05aef1af18d595b2f6f6e487fe1 to your computer and use it in GitHub Desktop.
Save bxb100/d31eb05aef1af18d595b2f6f6e487fe1 to your computer and use it in GitHub Desktop.
AWK 常见的一些使用方式

筛选出一个 function

从以 function digga() 开头的行到 } 开头行结束

awk '/^function digga()/,/^}/' .functions

获取文本中 m3u8 链接

正则获取有 m3u8 链接行, 然后正则替换 ; 为空字符, 然后打印以 -F fs( fs 默认为 white space ) 分隔的第 4 个字符串

awk '/https?\:\/\/.+\.m3u8/gsub(";", ""); print $4}' a.html

获取用户路径

guest:x:65534:65534:guest:/tmp:/bin/sh

cat passwd | awk -F ':' '{if ($1 == "xiaobo") print $6}'

awk example:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment