Search/replace in files using perl command line

August 15th, 2006

Here's a method for using a single perl command to search and replace for regular expressions in a file or multiple files

perl -pi -e s#orig text#replace text#g [filenames]

sshfs fstab entry

August 7th, 2006

Here's an example of a fstab entry for a sshfs mount.


# sshfs filesystems
# <file system> <mount point> <type> <options> <dump> <pass>
sshfs#username@remotesystem:/pub /mnt/pub fuse defaults 0 0

Ports - SSH Port Forwarding

August 7th, 2006

Here's some port numbers to remember:

VNC - 5900
Remote Desktop - 3389

ssh -l [remote user] -N -L [local port]:[target network machine name]:[target machine port] [target ssh machine]

Kill processes started by system

July 13th, 2006

Way, way too many times, I've seen some sort of process chewing up all my system processing cycles in Windows. Unfortunately, many times if I try to kill these processes, the system won't let me stating "access is denied". To work around this, use the following command to start up the task manager as "system".

at TIME /interactive taskmgr

where TIME is 1 minute from now.

bash loops and more

July 7th, 2006

Here's some examples of bash loops:

#!/bin/bash
for i in $( ls ); do
echo item: $i
done

#!/bin/bash
for i in `seq 1 10`;
do
echo $i
done

#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 10 ]; do
echo The counter is $COUNTER
let COUNTER=COUNTER+1
done

#!/bin/bash
COUNTER=20
until [ $COUNTER -lt 10 ]; do
echo COUNTER $COUNTER
let COUNTER-=1
done

For more information - check the Bash-Prog-Intro-HOWTO at the Linux Documentation Project

Additionally, here are some related pages:

Bash Shell Loop Over Set of Files
Bash Infinite Loop Examples
Syntax for a single-line Bash infinite while loop