20,027 reputation
34475
bio website
location United States
age
visits member for 3 years, 2 months
seen 4 hours ago

Debian user, GNU/Linux enthusiast, FLOSS supporter, hobby developer.


Jun
25
revised How can I cd to the previous/next sibling directory?
Use a more sensible glob to only match directories.
Jun
24
comment find n most frequent words in a file
@lukas Useless use of cat wastes a process and buys you absolutely nothing that shell redirection doesn't already do, in this case.
Jun
22
comment Is learning a text editor like vi necessary and still worth the time today?
<joke>Make sure you learn /bin/ed for the next time you need to rescue your fstab and /usr/bin won't mount because it's on a separate partition</joke>. Also, few graphical IDE's come close to offering the feature set of vim or emacs, and I can usually go off for a coffee break while waiting for the fancy IDE's to start.
Jun
22
revised Suppress output unless non-zero exit code
use a sub-shell for safety, and use less verbose syntax
Jun
22
comment Suppress output unless non-zero exit code
This should be the default behavior of most commands (no output on success). If not, the first thing to do is to look for an option / switch to enable such behavior. Failing that, your approach is the right idea. Side note: I'm assuming you posted pseudo-code because it is not actually valid sh syntax, and your redirection order is backwards (do > "$file" 2>&1 and use more quotes).
Jun
22
revised What is the difference between ~/.profile, ~/.bashrc, ~/.bash_profile, ~/.gnomerc, /etc/bash_bashrc, /etc/screenrc …?
added 331 characters in body
Jun
22
comment What is the most correct way to pass an array to a function?
I'm not familiar with ksh88, but if you need to pass the entire array by value, have you tried func "${array[@]}"? If you only need to pass one element, just pass the element - no need to make it more convoluted by passing an array and an index.
Jun
21
comment How can I cd to the previous/next sibling directory?
@Esteis Thanks for the edit.
Jun
20
revised How can I cd to the previous/next sibling directory?
added 222 characters in body
Jun
20
answered How can I cd to the previous/next sibling directory?
Jun
20
comment Why does `cat`ing a file into itself erase it?
Please don't recommend sed -i. It's not portable and probably doesn't even work correctly on links. Non-portable alternatives include cmd file | sponge file. Portable alternatives include ed (ed is a file editor; sed is a stream editor, not a file editor), which has more or less the same commands as sed, or a temporary file.
Jun
20
comment Why does `cat`ing a file into itself erase it?
@rahmu POSIX does specify the order but it doesn't need to because if you think about it for just a moment, you'll realize that the shell is the one that does the redirections and it has to do them before running the command, since it will be too late to do it after the command has already started. Add that bit of common sense to the fact that the > operator includes truncation and this behavior becomes very logical.
Jun
19
comment Remove directory in ftp
What OS? You are claiming you get a rmdir message by running rm. What travesty has been inflicted on your rm? Try type rm.
Jun
19
comment Mapping between logical and physical block device names
Everything in the /dev/mapper directory is typically a symlink to the actual device.
Jun
18
comment shorten long lines in a log file
Why use \{120\} if the OP asked for first 80 characters? Your command gets the first 120 and last 40 characters. There is no need to worry about the substitute changing short lines because short lines will never match the substitute pattern. If you really wanted to make sure short lines were untouched, you could specify the /.\{120,\}/ address for the substitute command.
Jun
17
revised Bash Linux random CLI Password generator and `<`
fix syntax error
Jun
14
revised What is the difference between ~/.profile, ~/.bashrc, ~/.bash_profile, ~/.gnomerc, /etc/bash_bashrc, /etc/screenrc …?
added 14 characters in body
Jun
14
revised What is the difference between ~/.profile, ~/.bashrc, ~/.bash_profile, ~/.gnomerc, /etc/bash_bashrc, /etc/screenrc …?
deleted 17 characters in body
Jun
14
revised What is the difference between ~/.profile, ~/.bashrc, ~/.bash_profile, ~/.gnomerc, /etc/bash_bashrc, /etc/screenrc …?
deleted 5 characters in body
Jun
14
comment Preventing access to TTY when X is killed
I just use startx & vlock. && and || wait for the previous process to terminate (possible race condition with keyboard interrupt Ctrl-c). You should also remember that physical access is game over as far as security goes, as anyone could pop in a tiny surreptitious keylogger or do any number of other things while you are away. I generally take the position of either giving up on security/trusting everyone who has physical access to my computer OR physically securing my computer (e.g. by keeping it with me) if I actually need my computer secured.