Is it possible to grab text from a online text file via grep/cat/awk or someting else? (in bash)
The way i currently do this is i download the text file to the drive and grep/cat into the file for it's text.
curl -o "$TMPDIR"/"text.txt" http://www.example.com/text.txt
cat/grep "$TMPDIR"/text.txt
rm -rf "$TMPDIR"/"text.txt"
Is one of the text grabbers (or another one) capable enough to grab something from a text file on the in开发者_开发百科ternet? This would get rid of the whole downloadfile-readfile-deletefile process and just replace it with one command, speeding up things considerably if you have a lot of those strings.
I couldn't find anything via the man pages or googling around, maybe you guys know something.
Use curl -o - http://www.example.com/text.txt | grep "something"
.
-o -
tells curl that it "downloads to stdout", other utils such as wget, lynx and links also have corresponding functionality.
You might try netcat - this is exactly what it was made for.
You could at least pipe your commands to avoid manually creating a temporary file:
curl … | cat/grep …
精彩评论