• Страхиња Радић [2024-03-21 16:31]:
On 24/03/20 08:15AM, Kirill Miazine wrote:
#!/bin/sh
ifconfig wg1 | \
grep wgaip | \
awk '{print $2} ' | \
grep /32$ | \
sed 's/\/32//' | \
sort | while read x; do
ping -w 1 -c 1 $x 2>&1
done
Just FYI, you don't need backslashes (\) here, as the command ending with a
pipe is an incomplete pipeline. ;-)
ah, thanks a lot, good to know!
in this case I added escaped newlines when posting, i have all on one
line, but I think i could have scripts where a pipe is followed by
escaped newline. have to check that one.
i see some scripts in /etc also use escaped newlines after pipes:
root@stable ~ # grep -r '| \\$' /etc/
/etc/daily: baksize=`disklabel $bakdisk 2>/dev/null | \
/etc/daily: rootsize=`disklabel $rootdisk 2>/dev/null | \
/etc/weekly: echo "${UPDATEDB} --fcodes=-" | \