Предложение:
#!/bin/sh
# Look at filenames in current directory and generate list with filename
# suffixes removed (a filename suffix is anything after the last dot in
# the file name). We assume filenames that does not contain newlines.
# Only unique prefixes will be generated.
for name in./*; do
[ ! -f "$name" ] && continue # skip non-regular files
printf '%s\n' "${name%.*}"
done | sort -u |
while IFS= read -r prefix; do
# Set the positional parameters to the names matching a particular prefix.
set -- "$prefix"*
if [ "$#" -ne 2 ]; then
printf 'Not exactly two files having prefix "%s"\n' "$prefix" >&2
continue
fi
# Check file sizes and remove smallest.
if [ "$( stat -c '%s' "$1" )" -lt "$( stat -c '%s' "$2" )" ]; then
# First file is smaller
printf 'Would remove "%s"\n' "$1"
echo rm "$1"
else
# Second file is smaller, or same size
printf 'Would remove "%s"\n' "$2"
echo rm "$2"
fi
done
Это предполагает GNU stat
.
Да, это возможно.
Следующая последовательность команд должна сделать это:
INTERFACE_IP="192.168.0.1" # IP address of the external interface (e.g. eth0)
INTERFACE_PORT="80" # external port to forward
LOCAL_IP="127.0.0.1" # internal ip address to forward to
LOCAL_PORT="8080" # internal port to forward to
/usr/sbin/iptables -t nat -A PREROUTING -d $INTERFACE_IP --dport $INTERFACE_PORT -j DNAT --to-destination $LOCAL_IP:$LOCAL_PORT
или чуть менее динамичный:
/usr/sbin/iptables -t nat -A PREROUTING -d 192.168.0.1 --dport 80 -j DNAT --to-destination 127.0.0.1:8080
Порт назначения (:8080 )можно не указывать, если это тот же порт, что и входящий.
Имейте в виду, что другие правила в вашем iptables могут вызвать проблемы с этим правилом!!