Check These Out
on multihomed hosts, connected to several networks, could be usefull to know the source address (local ip address) used to reach the target host, this command does not require root priviledges.
The command use a TCP socket, if there is any error the command return an empty string, elsewhere return a valid ip address.
Force an fsck on reboot. Useful on a system where / has mounted read-only because of file system issues.
I put this in a shell script called "svndiff", as it provides a handy decorated "svn diff" output that is colored (which you can't see here) and paged. The -r is required so less doesn't mangle the color codes.
You could do the following, however, brace expansion with {} is not defined in POSIX, and therefore not guaranteed to work in all shells. But, if it does, it's more convenient (although it's certainly not less typing):
$ cp -r {*,.??*} /dest
Sometimes there are times when I need to cp(1), mv(1) or rm(1) files recursively, but don't want to traverse the previous directory by following ../../../../ etc out of the current directory. This command prevents that. The secret sauce is ".??*". The file globbing ensures that it must start with a dot, and be followed by at least two characters. So, three characters must exist in the filename, which eliminates "." and "..".
An easy function to get a process tree listing (very detailed) for all the processes of any gived user.
This function is also in my http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
Converts any number of seconds into days, hours, minutes and seconds.
sec2dhms() {
declare -i SS="$1"
D=$(( SS / 86400 ))
H=$(( SS % 86400 / 3600 ))
M=$(( SS % 3600 / 60 ))
S=$(( SS % 60 ))
[ "$D" -gt 0 ] && echo -n "${D}:"
[ "$H" -gt 0 ] && printf "%02g:" "$H"
printf "%02g:%02g\n" "$M" "$S"
}
Replaces the first instance of 'foo' with 'bar'. To replace all instances of 'foo' with 'bar': !!:gs/foo/bar/
Simple use of find and grep to recursively search a directory for files that contain a certain term.