How can i cat a remote file? Where it works for local file 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, use wget -O- -q
, which reads a document over HTTP and writes it to standard output:
for i in $(wget -O- -q http://localhost/1/downloads.txt)
(The -O...
option means "write to the specified file", where -
is standard output; the -q
option means "quiet", and disables lots of logging that would otherwise go to standard error.)