Check These Out
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"
Safe for whitespaces in names.
Shows all block devices in a tree with descruptions of what they are.
Using this command you can track a moment when usb device was attached.
Trace python statement execution and syscalls invoked during that simultaneously
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"
syntax follows regular command line expression.
example: let's say you have a directory (with subdirs) that has say 4000 .php files.
All of these files were made via script, but uh-oh, there was a typo!
if the typo is "let's go jome!" but you meant it to say "let's go home!"
find . -name "*.php" | xargs perl -pi -e "s/let\'s\ go\ jome\!/let\'s\ go\ home\!/g"
all better :)
multiline: find . -name "*.php" | xargs perl -p0777i -e 's/knownline1\nknownline2/replaced/m'
indescriminate line replace: find ./ -name '*.php' | xargs perl -pi -e 's/\".*$\"/\new\ line\ content/g'
I like much more the perl solution, but without using perl. It launches a backgroup process that will kill the command if it lasts too much.
A bigger function:
check_with_timeout() {
[ "$DEBUG" ] && set -x
COMMAND=$1
TIMEOUT=$2
RET=0
# Launch command in backgroup
[ ! "$DEBUG" ] && exec 6>&2 # Link file descriptor #6 with stderr.
[ ! "$DEBUG" ] && exec 2> /dev/null # Send stderr to null (avoid the Terminated messages)
$COMMAND 2>&1 >/dev/null &
COMMAND_PID=$!
[ "$DEBUG" ] && echo "Background command pid $COMMAND_PID, parent pid $$"
# Timer that will kill the command if timesout
sleep $TIMEOUT && ps -p $COMMAND_PID -o pid,ppid |grep $$ | awk '{print $1}' | xargs kill &
KILLER_PID=$!
[ "$DEBUG" ] && echo "Killer command pid $KILLER_PID, parent pid $$"
wait $COMMAND_PID
RET=$?
# Kill the killer timer
[ "$DEBUG" ] && ps -e -o pid,ppid |grep $KILLER_PID | awk '{print $1}' | xargs echo "Killing processes: "
ps -e -o pid,ppid |grep -v PID | grep $KILLER_PID | awk '{print $1}' | xargs kill
wait
sleep 1
[ ! "$DEBUG" ] && exec 2>&6 6>&- # Restore stderr and close file descriptor #6.
return $RET
}
remove all compressed files in /home/ folder not created in the last 10 days