The Archives
-
11.06.08man man$ man man Some useful info not to be underestimated.
-
10.31.08Adding line numbers to a file$ cat -b /etc/inittab 1 root:x:0:root 2 bin:x:1:root,bin,daemon 3 daemon:x:2:root,bin,daemon 4 sys:x:3:root,bin,adm 5 adm:x:4:root,adm,daemon 6 tty:x:5: 7 disk:x:6:root 8 lp:x:7:daemon,lp 9 mem:x:8: 10 kmem:x:9: 11 wheel:x:10:root 12 mail:x:12:mail 13 news:x:13:news 14 uucp:x:14:uucp ...
-
10.29.08Opening a file with vi at specified position$ vi +10 /home/rafacas/test.txt Opens the file test.txt with the vi editor and positions the cursor on line 10.
-
10.11.08screen… ttys as window managers (1)You either know it (in which case you probably will not bother to read on) or you must know it (and here I come to the rescue). Open your terminal of choice (in my OS X interface I press Command-0, which invokes quicksilver and then 'it <ret>', with which I get an iTerm instance). Then type $ screen and a help text appears, showing the usual GNU license text; press Return to continue. The screen blanks out as if you had just started your session. You are in, this is the red pill. You will never want out. Screen is a fully-featured 'terminal' window ...
-
09.17.08Time$ time for i in `ls` ; do cat $i ; done Shows the 'real', 'user' and 'sys' time invested in the task.
-
09.03.08Taking screenshots$ import -window root screenshot.jpg Takes a shot of the whole desktop and saves it in screenshot.jpg. import is part of the ImageMagick suite.
-
08.28.08Listing files ordered by date$ ls -lt Lists files ordered by date starting at the newest one.
-
08.19.08Copying preserving attributes$ cp -p /home/rafacas/file1 /tmp Copies preserving attributes (mode, ownership, timestamp) from the indicated files.
-
08.15.08Looking at the EndFrom time to time we want to see only a few lines near the end of a file. We often use cat or more, but this can be tedious when the file is big (like a very long log file). You can use these commands to read from the end of the file: tac. It works exactly as cat but reading from the end of the file tail. It reads from the end of the file. It has more features than tac. The one I found to be more interesting is the -f flag. It makes tail to continue reading from the ...
-
07.17.08Roll the diceNot a command, but a fun thing anyway. What if you need a dice (as I needed the other day while trying to play a game with my friends) and you don't have one? Bash can do it: $ while true;do let dice="$RANDOM % 6"; let dice=$dice+1;echo $dice;read;clear;done Though it's a long line, this is just an infinite loop in which we use the $RANDOM bash variable which generates a random number between 0 and 32767. After that, we divide it by 6 and take the remainder (so we have a number between 0 and 5) and add 1 to shift the interval ...