Posts Tagged bash

iptables fun and games

Note to self: When configuring iptables, don’t copy + paste

/sbin/iptables -F
/sbin/iptables -P INPUT DROP
<bunch of other commands>

into bash.

I had A Bad Time.

, , ,

No Comments

find/xargs/grep tricks

Because xargs will die if you have an unescaped quote, but using -0 screws everything up if you’re reading a list of files:

sed s/\'/\\\\\'/|cut -d \: -f 1|xargs -i rm "{}"

The sed pattern will put the escape character in front of any single quotes so that xargs doesn’t screw up.

Using md5sum to compare files, use grep -v FAILED to quickly get a list of files that passed the md5 check.

Feed it into xargs to delete the files:

grep -v FAILED|sed s/\'/\\\\\'/|cut -d \: -f 1|xargs -i rm "{}"

,

No Comments