Reputation
1,563
Top tag
Next privilege 2,000 Rep.
Edit questions and answers
Badges
5 19
Newest
 Informed
Impact
~168k people reached

Oct
28
comment Is it considered a best practice to not use capital letters in file naming?
On many keyboards, ctrl-space or ctrl-@ or alt-0 will type a NUL.
Oct
26
answered Recursive find/replace, taking directory depth into consideration
Oct
13
comment How to substite a " in awk?
This is the easiest way to do it in awk. But for completeness, Wouter Verhelst's second awk example also works: awk 'sub("\"", "quote")'. And so too does llua's example.
Oct
13
comment How to substite a " in awk?
The first awk example won't work, for two reasons. First, awk unlike Python doesn't recognize 'blah' as a string. Strings have to be inside double quotes. Second, you can't escape single quotes inside single quotes in the way you're imagining. 'blah\'more' isn't a single quoted string containing a single quote. Instead, the single quote after blah terminates the string. To escape single quotes from the shell, you have to instead do 'blah'\''more'. The first single quote after blah terminates the single quoted string. Then \' gives the shell a single quote. Then a new string begins.
Oct
8
comment Command line processing - tokens and metacharacters
In practice, an isolated metacharacter (like |) or some sequences of them(like || or >&) will also constitute tokens; that's why the sentence goes on to say that redirectors (>, <, >&, and so on) are tokens. But the sentence in your book isn't formulated in a way to acknowledge this. I agree with you that as it's written, the metacharacters aren't themselves tokens. The sentence as written is incorrect.
Oct
4
comment Skip 'natural' exit in trap
@tripleee the OP wants the trap to run on normal (non-signalled) exits but only when the exit code is > 0.
Oct
1
comment Skip 'natural' exit in trap
Huh, I was skeptical, but I just confirmed you are right. Tested on a v3 bash as well as a BusyBox sh (variant of ash), works as you say in both cases.
Oct
1
comment Skip 'natural' exit in trap
trap specifies which signals the dd-destroy.sh... command should be invoked on. I don't know of any way for that command to test what the error code was when getting an EXIT signal. I'd recommend creating a function that has your dd-destroy.sh ... stuff in it; have the trap line invoke that function but omit the signal EXIT; and replace your exit 1 with { that_function; exit 1; }.
Oct
1
awarded  Informed
Oct
1
comment String comparison failing in bash
Better to do [ green = "$i" ]. That avoids errors if i contains something like -n. This is a good general practice, because that can make some shells choke. (This is the reason why you'll sometimes see [ "x$a" = "x$b" ].) Bash is a bit smarter about this, but I don't know if it's smarter when using single [ ... ] as opposed to [[ ... ]].
Sep
30
comment What happens when I echo with `-e` argument?
@Archemar is right. You most likely want to use \n rather than \r.
Sep
30
revised “date -d” command fails on Docker Alpine Linux container
Remove /alpine tag; this was the only question about Alpine Linux, others were about Alpine mail (also proposed usage blurb for the tag)
Sep
30
suggested approved edit on “date -d” command fails on Docker Alpine Linux container
Sep
30
suggested rejected edit on alpine tag wiki excerpt
Sep
30
awarded  Custodian
Sep
30
reviewed No Action Needed TigerVNC is running, but not listening on any port?
Sep
30
reviewed No Action Needed Is grep part of coreutils? (If not, why?)
Sep
30
reviewed No Action Needed Create files from templates, substitutions in middle of other words
Sep
29
comment What C library version does my system use?
Nice answers, but no one addresses how to do this on a Mac, where there is no ldd. I'm not sure if otool --version can be regarded as giving the same information.
Sep
29
suggested rejected edit on Remove character from string at specific location