#!/bin/sh
TM=`date +"%H-%M"`
DOM=`cat /mnt/test_dom`
for f in $DOM
do
if curl -Is --connect-timeout 5 https://$f 2>/dev/null; then
else
echo "Domain "$f" block, time ${TM}." | mail -s "Domain "$f" block, time ${TM}." [EMAIL]local@mail.local[/EMAIL]
sed -i '/$f/d' /mnt/test_dom
fi
done
exit 0
The old script was mistaken.Nope, your syntax is still wrong. The examples given in this thread are correct. But to understand what the (required) parameter to-i
does, just read the manpage. That's what theses pages are written for…
sed -i '' -e '/$f/d' /root/test_dom
$f
variable is in single quotes, thus it's not getting expanded but taken verbatim. There is a difference between "$f"
and '$f'
:#!/bin/sh
FOO="bar"
echo "$FOO"
echo '$FOO'
The$f
variable is in single quotes, thus it's not getting expanded but taken verbatim. There is a difference between"$f"
and'$f'
:
Code:#!/bin/sh FOO="bar" echo "$FOO" echo '$FOO'
This is shell scripting 101.
sh
script and the FreeBSD sh
is very close to a conformant POSIX shell, perhaps the most specific explanation from the Grymoire, including weak versus strong quoting, and other sh
specifics is: Quoting within the ShellIn my opinion it is misleading to have the words "quoting" and "simple" in one sentence .