jueves, noviembre 01, 2007

Mandar mails desde el shell de Linux

1. mail emystein@gmail.com -s "test"
2. Enter
3. Tipear el mensaje
4. Presionar CTRL+D
5. Si se desea, ingresar una dirección de mail para cc (carbon copy)
6. Presionar Enter
7. Voilá

Se pueden usar pipes:
tail -100 /var/logs/messages | mail emystein@gmail.com -s "Logs"

miércoles, enero 03, 2007

Linux: Counting Files in the Current Directory

To determine how many files there are in the current directory, put in ls -1 | wc -l. This uses wc to do a count of the number of lines (-l) in the output of ls -1. It doesn't count dotfiles. (in ls -1, is "one" instead of "L")
If you want to count only files and NOT include symbolic links (just an example of what else you could do), you could use ls -l | grep -v ^l | wc -l (that's an "L" not a "1" this time, we want a "long" listing here). grep checks for any line beginning with "l" (indicating a link), and discards that line (-v).