问题
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