Reputation
3,090
Top tag
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
9 38 65
Impact
~363k people reached

Feb
12
comment Provide default value if command returns with non-zero exit code
Ah! I could pipe stderr to /dev/null and it works: cat config 2> /dev/null || echo 42.
Feb
12
comment Provide default value if command returns with non-zero exit code
I'm not quite sure I understand how the trap logic would be combined with the cat config command from the example. Can you elaborate?
Feb
12
comment Provide default value if command returns with non-zero exit code
The critical problem here is that it's the output of the commands that I care about. cat config gives an error cat: config: No such file or directory if config doesn't exist. So I end up getting the output of both commands instead of just the second one.
Feb
12
comment Provide default value if command returns with non-zero exit code
Well... I could write a script that essentially does the same thing as above, but I was hoping that there was built-in bash syntax that supported this kind of a thing and I just hadn't learned about it yet. If no such bash syntax exists I guess the next best thing is a script, and the best script would be an elegant succinct one.
Feb
12
comment Provide default value if command returns with non-zero exit code
This appears to work for the cat config example, but I was hoping for a solution that works regardless of whether the failure is due to a missing file. For example ./get_config_from_web.sh || echo 42.
Sep
25
comment dpkg-query listing package that is not installed
@derobert Updated question with that info.
Mar
12
comment How do you write specific bytes to a file?
With that, I get a\na\na, is that supposed to be what I see?
Mar
12
comment How do you write specific bytes to a file?
That's a pretty impressive 3-liner. I'd be interested if you cared to elaborate on that regex!
Sep
30
comment grep search expression and rename file
So is VAX00002885 the name of the file, or a string found inside the file?
May
12
comment How do you move all files (including hidden) from one directory to another?
Personally, I think *nix specific questions and answers should be off-topic on SU. With the current rules we end up with tons of content collisions between the two - like this question.
May
12
comment How do you move all files (including hidden) from one directory to another?
Not the best when you're moving a lot of large files, but I guess it would work.
Nov
25
comment How can I get my external IP address in bash?
@daSong Don't you mean whatismyip.org?
Nov
7
comment What is a regular file?
Ah, you're right - it's aliased to rm -i.
Nov
6
comment Default exit code when process is terminated?
How in the world do you find this, or even know where to look? I bow before your genius.
Oct
21
comment Open VirtualBox GUI?
Turns out I had to install virtualbox-qt, then virtualbox showed up in dmenu (since I'm using xmonad).
Oct
16
comment Nicely close windows in xmonad?
This may work for Chrome, but it still would be nice to have something I could use for any window.
Oct
3
comment Install debug flash player in Chrome?
64-bit. Linux ckleinlx 3.8.0-31-generic #46-Ubuntu SMP Tue Sep 10 20:03:44 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Sep
23
comment Reset atq list to zero?
@terdon I saw something where I thought "hmm, I don't understand how that works!" but I couldn't figure it out on my own, so I came here!
Sep
23
comment Reset atq list to zero?
@terdon Naw, it's just idle curiosity. I was curious that none of the files in FILES section of man at seemed to have a reference to this identifier, so I wondered where the number could possibly come from?
Sep
23
comment Reset atq list to zero?
For some reason I can't restart my atd service, I get a start: Rejected send message... error. Do you think that restarting the service would reset that number?