How to access an online txt file with AWK?

拜拜、爱过 提交于 2019-12-10 17:53:48

问题


I would like to use an online database instead of a local file in AWK. For instance:

awk 'END{print NR}' somelocalfile.txt

returns number of lines inside the file.

Now my question is, how can I calculate number of lines in an online txt file like this one? I prefer one-liner command.

I can wget and then apply awk command localy on it, but I think there can be more efficient approach.


回答1:


I would suggest to use wget:

wget -qO - http://path.com/tofile.txt | awk 'END{print NR}'

q means quiet, so you won't have any terminal outputs from wget. -O is the output which is set to stdout with the '-O -'.



来源:https://stackoverflow.com/questions/35523808/how-to-access-an-online-txt-file-with-awk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!