toplogo.png
up Home Computers Commands
From http://craig.backfire.ca/pages/computers/commands

These are all little things I type on the command line to do various tasks. They don't have much in the way of error handling, but they sure are useful. They are all for Bourne-compatible shells on FreeBSD, unless specified otherwise. These can also be used to do similar tasks; they aren't all one-trick ponies.


Delete files from a list in list.txt.

perl -nle unlink < list.txt

Find corrupt JPEG images in the current directory.

find . -iname \*.jp\* -exec jpeginfo -cq {} \; | grep -v '[OK]'

Ping the default route, useful for testing internet connectivity.

ping `netstat -rn | awk '/default/ {print $2}'`

Run COMMAND every N seconds.

while sleep N ; do COMMAND ; done

Run COMMAND, and suppress all of its output, good or bad.

COMMAND > /dev/null 2>&1

Watch a text file be appended.

tail -f file

Grab the decription of a sysctl

sysctl -d kern.ipc.nmbclusters

Check the interrupt count and interrupt rate of all devices.

vmstat -i

Create a whole bunch of symlinks all at once.

for S in cars bikes planes
 do
  ln -s /home/images/${S} /home/craig/${S}-images
done

Get a nice little table of contents for FreeBSD manpages.

 for M in `jot 9 1` ; do (man $M intro | head -1) 2>/dev/null ; done

Get the size of the current working directory in bytes. Useful for further scripting.

find . -type f | perl -nle '$size += -s; END {print $size}'

List installed packages that are out-of-date, have a corrupted list, or are otherwise not perfect, and provide a line count at the end.

pkg_version -vL= | tee /dev/stderr | wc -l

Delete all ports, and then install them again, without handling any errors or avoiding repetition from building dependencies more than once.

cd /tmp
pkg_info -aoq > pkgtmp
pkg_delete -fa
for F in `cat pkgtmp`
 do
  cd /usr/ports/${F}
  make install clean
done

Rate This Page

Mouse over the nuts to rate. ZERO NutsOne NutTwo NutsThree NutsFour NutsFive Nuts 

Page last modified on December 29, 2009 16:55:45. (ID=64)