Reputation
421
Top tag
Next privilege 500 Rep.
Access review queues
Badges
2 5
Newest
 Yearling
Impact
~8k people reached

Apr
7
comment About executing shell script
Note that back when Kernighan&Pike was written, it was common to have the current directory (".") in the PATH (meaning that foo.sh would work without the ./). This was a found to be a security problem (someone could leave e.g. a malicious script named "ls" in their directory, then trick other people into running it), so it's no longer common (or recommended) practice.
Mar
24
comment Why doesn't $@ work when passing strings?
@orangeorange You can't safely store multiple arguments in a plain variable. But you can store them in an array with t=("$@"), and then reference it as "${t[@]}" to recover the original argument list intact. Note that all of the double-quotes I used are necessary.
Jan
20
awarded  Yearling
Jan
20
answered Quoting / escaping / expansion issue in “command in a variable”
Jan
4
awarded  Citizen Patrol
Nov
24
comment How can variables use “~” for cd'ing?
@hvd: you actually have to leave the slash unquoted as well. BASE=~/"quoted name" works, but BASE=~"/quoted name" doesn't.
Nov
10
comment Emulating /etc/cron.d/ on OSX
Ah, I misunderstood; in that case, the answer is that OS X's version of cron doesn't have that feature. But actually, I'd argue that since you'd have to do it differently on OS X anyway (adding a line to /etc/crontab rather than dropping a file in /etc/cron.d), you might as well go all the way and drop a file in /Library/LaunchDaemons instead.
Nov
10
answered Emulating /etc/cron.d/ on OSX
Jul
24
comment bash script loses readonly value after first time thru loop
If double-quotes around the array reference are causing trouble, I'm pretty sure there's something wrong with how the array is being constructed; removing the double-quotes should not be necessary. I'd concentrate on figuring out what's building the array wrong.
Jul
2
answered Piping content with multiple spaces
Jun
26
answered user input not accepted in nested case statement
Jun
17
comment How Does Linux deal with shell scripts?
This behavior is version-dependent. I tested with bash version 3.2.51(1)-release, and found that it didn't buffer past the current line (see this stackoverflow answer).
Jun
15
awarded  Commentator
Jun
15
comment Comparison of decimal numbers in bash
To illustrate the importance of the difference between string vs. numeric comparison, consider that [[ 11.56 < 2.90 ]] (and [[ ((11.56 < 2.90)) ]] and...) is true, because "1" comes before "2" in ascii sorting order.
May
19
comment Why do bash variables disappear when I use xargs?
In this case, I think >( ) is the form wanted. Something like ... done > >(xargs ... )
Apr
30
answered bash_profile stops after file call
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.