我尝试使用 MAWK,其中match()
内置函数没有第三个变量值:
match($1, /9f7fde/) {
substr($1, RSTART, RLENGTH);
}
见文档。
var
当以后我想像这样构造我的输出时,如何将此输出存储到一个名为的变量中?
EDIT2 - 完整示例:
输入文件结构:
<iframe src="https://vimeo.com/191081157" frameborder="0" height="481" width="608" scrolling="no"></iframe>|Random title|Uploader|fun|tag1,tag2,tag3
<iframe src="https://vimeo.com/212192268" frameborder="0" height="481" width="608" scrolling="no"></iframe>|Random title|Uploader|fun|tag1,tag2,tag3
解析器.awk:
{
Embed = $1;
Title = $2;
User = $3;
Categories = $4;
Tags = $5;
}
BEGIN {
FS="|";
}
# Regexp without pattern matching for testing purposes
match(Embed, /191081157/) {
Id = substr(Embed, RSTART, RLENGTH);
}
{
print Id"\t"Title"\t"User"\t"Categories"\t"Tags;
}
预期输出:
191081157|Random title|Uploader|fun|tag1,tag2,tag3
我想在函数Id
外调用变量。match()
MAWK 版本:
mawk 1.3.4 20160930
Copyright 2008-2015,2016, Thomas E. Dickey
Copyright 1991-1996,2014, Michael D. Brennan
random-funcs: srandom/random
regex-funcs: internal
compiled limits:
sprintf buffer 8192
maximum-integer 2147483647