How can I cat a remote file? Currently, it works for local files only.
#!/bin/bash
regex='url=(.*)'
# for i in $(cat /var/tmp/localfileworks.txt);
for i in $(cat http://localhost/1/downloads.txt);
do
echo $i;
# if [[ $i =~ $regex ]]; then
#echo ${BASH_REMATCH[1]}
#fi
done
cat: http://localhost/1/downloads.txt: No such file or directory
Instead of
cat, which reads a file from the file-system, usewget -O- -q, which reads a document over HTTP and writes it to standard output:(The
-O...option means “write to the specified file”, where-is standard output; the-qoption means “quiet”, and disables lots of logging that would otherwise go to standard error.)