216 reputation
13
bio website
location
age
visits member for 3 years
seen Apr 16 at 15:51

Feb
3
awarded  Yearling
Jan
31
answered UDP commands for Linux and Mac?
Sep
19
answered How can I mimic `sudo su - user` in a script?
Aug
28
comment How to clear environment variables in launchd?
Each process has its own separate set of environment variables. The export command only exports a variable to subprocesses created by that particular shell process (and only those it spawns after the export command). There is no way for one shell to change the environment of another running process.
Feb
3
awarded  Editor
Feb
3
revised What is Darwin's 'private' directory for?
Added note on incompleteness
Feb
3
answered What is Darwin's 'private' directory for?
Apr
2
comment How can I create a file with multiple lines from the command-line?
Yup. I've been bitten when echo's behavior changed in a system update, and some of my scripts broke...
Feb
25
comment Exporting environment variable
Don't use eval $hello, use eval "$hello". Without the double-quotes, some unwanted parsing is done, which can cause very weird bugs. See this answer for an example (in a rather different situation, but the same principles apply).
Apr
25
comment How to get only the unique results without having to sort data?
The awk version can be made even shorter by leaving out the if, print, parentheses, and braces: awk '!seen[$0]++'
Apr
21
answered No exec permissions on programs in /usr/local/bin
Apr
12
awarded  Supporter
Apr
11
awarded  Teacher
Apr
11
answered Linux - command to list files (except ls)
Dec
15
comment How do I correct a directory incorrectly copied into itself?
Are you trying to merge the two mydir directories? I don't think the mv command can do that...
Dec
15
comment How do I correct a directory incorrectly copied into itself?
Oops, I had the path in the rm command wrong; I've edited the answer to correct it.
Dec
15
answered How do I correct a directory incorrectly copied into itself?
Sep
25
comment How do I force the user to become root
It's sometimes good to run sanity checks (e.g. does the file in question exist?) before sudo'ing -- I tend to do this by starting the script with something like if [[ $1 == "--no-sanity-checks" ]]; then shift; else run sanity checks; fi and then modify the sudo command to exec sudo "$0" --no-sanity-checks "$@"
Sep
23
comment How do I force the user to become root
Note that if it's run as a function like this, you need to pass in the script's parameters (i.e. run it with rootcheck "$@"). Or you can just put the if block inline rather than in a function. Also, this should be done very early in the script, as anything before it will be run twice (once normally, once as root).