[Gllug] Stories of using filters
Russell Howe
rhowe at wiss.co.uk
Thu Mar 17 12:45:43 UTC 2005
On Thu, Mar 17, 2005 at 06:41:00AM +0000, Steve Nelson wrote:
> Would people like to contribute some real-life examples of using:
>
> od, nl, paste, tr, cut, fmt, expand, join, pr, cut, tac, split
Using none of the above... :)
Replacement for dpkg -S which is quite a bit faster:
find /var/lib/dpkg/info/ -maxdepth 1 -name '*.list' -print0 \
|xargs -0 -P 0 -r grep "$1" \
|sed -e 's,/var/lib/dpkg/info/\([^:]\+\).list:,\1: ,'
As an aside, here's a bit of shell script I wrote: Load it into vim and
watch the syntax hilighting break:
netmask_to_cidr() {
echo "$1"| (
IFS=.
read NM1 NM2 NM3 NM4
NMDEC="$(((NM1 << 24) + (NM2 << 16) + (NM3 << 8) + NM4
))"
if [ "$NMDEC" -gt $((0xffffffff)) -o "$NMDEC" -lt 0 ];
then
echo "Invalid IPv4 netmask!" >&2
exit 1
fi
NM_BITS=0
while [ "$NMDEC" -ne 0 ]; do
NMDEC="$(((NMDEC << 1) & 0xffffffff))"
NM_BITS="$((NM_BITS + 1))"
done
return "$NM_BITS"
)
}
--
Russell Howe | Why be just another cog in the machine,
rhowe at siksai.co.uk | when you can be the spanner in the works?
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list