Reputation
380
Top tag
Next privilege 500 Rep.
Access review queues
Badges
1 13
Newest
 Organizer
Impact
~15k people reached

Apr
6
comment Why isn't this directory being added to my PATH when I use sudo?
I'd rather create that symlink in /usr/local/bin, not /usr/bin. The latter should be reserved for packages installed by the package manager.
Feb
24
comment How to tell if output of a command or shell script is stdout or stderr
Note that if there's mixed output from stdout and stderr, first stdout will be printed, then stderr.
Jan
20
comment How to represent date format in '2015120' in Linux shell?
@MichaelKjörling It's funny how that xkcd lists 20130227 as a discouraged format, when it's in fact also defined by ISO 8601. (Of course, using hyphens is preferable if humans are going to read the date.)
Dec
22
comment How do I run a command and get its exit code in fewer characters?
The second example shouldn't include [ and ] around the commands.
Dec
20
comment Switch to parent shell without logging out
@StéphaneChazelas I didn't think of that. That's a good point.
Dec
20
comment Switch to parent shell without logging out
@StéphaneChazelas $$ is a read-only variable, though, and you can make assumptions about its value. That said, I do quote those variables when using them.
Dec
20
comment Switch to parent shell without logging out
@StéphaneChazelas Does that really make a difference with a variable that's almost certainly guaranteed to contain a numeric value?
Dec
13
comment Extracting the second word from a string variable
echo is not portable for anything other than a literal string that doesn't start with - and doesn't contain any escape sequences. Its behavior varies even for the bash builtin, depending on how it was compiled, and whether XPG_ECHO is set. Also, you should always double quote variable expansions and command substitution (with certain exceptions, where it's not necessary but it doesn't do any harm either). With a string like the OP's, this should be fine, but if you want to make sure printf '%s\n' "${a##* }" would be better.
Dec
13
comment Extracting the second word from a string variable
echo is not portable for anything other than a literal string that doesn't start with - and doesn't contain any escape sequences. Its behavior varies even for the bash builtin, depending on how it was compiled, and whether XPG_ECHO is set. Assuming the string contains no escape sequences, this should be fine, but printf '[%s]\n' "$y" is still better.
Dec
1
comment Automatic login via ssh (no GUI environment installed / no ssh-agent available)?
Then why are you talking about entering the nonexistent passphrase later on? [...] prepare the system for batch SSH usage by entering the passphrase [...]
Dec
1
comment Automatic login via ssh (no GUI environment installed / no ssh-agent available)?
You can use SSH keys which have no passphrase. If you don't like that idea then you can create a key file without passphrase [...] This doesn't make sense.
Nov
6
comment How do I set a user environment variable? (permanently, not session)
This is not a full answer, but if it's shell-specific, I recommend putting it in .bashrc; if it's not, put it in .profile. I source .profile and .bashrc (in that order) from .bash_profile, and make sure to put [[ $- != *i* ]] && return on the top of .bashrc.
Nov
5
comment Modify a file without creating another file
I can't see any globs there.
Nov
5
comment Modify a file without creating another file
I submitted an edit with some improvements. While it may not exactly be suitable for an edit, I'm hoping to save you some work.
Nov
5
suggested rejected edit on Modify a file without creating another file
Nov
5
comment Modify a file without creating another file
I think you forgot to define pattern and replacement, too.
Nov
5
comment Modify a file without creating another file
Also, if it's a bash script, you can just do grep -q "$pattern" <<< "$line".
Nov
5
comment Modify a file without creating another file
That script suffers from multiple issues. (1) read line should be read -r line. (2) The $() in the if is redundant. I'm surprised if that even works. (3) echo suffers from a lot of portability issues even within bash. Use printf '%s\n' "${var}" instead. (4) $1 should be wrapped in double quotes: "$1".
Nov
5
comment Getting 256 colors to work in tmux
-1, you shouldn't set either unconditionally in your shell initialization file. Setting it to xterm-256color will override it inside tmux as well, and setting it to screen-256color outside of tmux could lead to display bugs.
Nov
4
revised Adding to path vs. linking from /bin
edited body