Reputation
549
Top tag
Next privilege 1,000 Rep.
See vote count; VIP usercard
Badges
3 11
Impact
~18k people reached

  • 0 posts edited
  • 0 helpful flags
  • 235 votes cast
Apr
11
comment Strange behaviour of “ls -a | grep ^\.”
A cautionary note: Never pipe the output of ls into another command. Use find instead. ls has way too many ideosyncrasies to be trusted. See: Pitfall 1 at mywiki.wooledge.org/BashPitfalls - it made #1! The rest of the site is great too.
Apr
11
comment Displaying “No Results” When AWK Command has no output
@Doug - awk is your friend. It's almost as day to day useful as grep, find, and sed - and a lot easier to debug than any of those when things go wrong. A little time learning it will pay you back many times over.
Apr
11
comment How do you check if a file exists within awk? [-d 'filename'] failing
As @terdon notes, [ -d "$6"] is actually bash syntax, not awk. The [ looks like normal syntax, but (in one of bash/Linux's better weirdnesses) it's actually a synonym for the test executable program (or maybe a bash built-in version of it, and, just to be weirder, bash requires a matching ] that doesn't do anything I'm aware of other than to mislead you to think that the whole thing is really syntax and not a program). In any case, it's not something awk knows about. That's why you need the system() function to access it by referencing it in the context of bash where it is understood
Apr
8
revised How do I use man pages to learn how to use commands?
added content
Apr
6
revised Transpose a file, and replace missing values
Removed promise of additional code after no feedback from the OP for this much.
Apr
4
answered How do I use man pages to learn how to use commands?
Apr
3
comment Is using “while true” to keep a script alive a good idea?
If you know the file is good before it leaves the pi, then you could just run a checksum like md5 or sha1 and send that along with your file. Then the receiver will know if it got a bad file before it tries to process it. If you don't know that, then you can still build some sort of partial or block checksums or something similar into your data file which insures data integrity, so you can check things as you go before you commit to a process which can fail. An ounce of prevention ...
Apr
3
comment rsync's --link-dest option does not link identical files if an old file exists
If you don't get the answer you need here, you can post on the rsync list. The rsync developers regularly answer questions there along with many advanced users. You can find them via lists.samba.org/mailman/listinfo/rsync . I mostly lurk there and learn a lot.
Mar
25
revised An alternative to `xdotool type`
outdated link
Mar
22
comment When can I edit strings in an executable binary?
Good answer. sed can do lots of things, but, in general, that's what binary editors were invented for. They can be challenging to use when navigating within a large binary file, but they will let you change things byte by byte. I use hexedit when I have to examine or change a binary file. You can use strings -t x file | less to locate the offsets of the (printable) strings you want to change before jumping into the editor.
Mar
7
revised Transpose a file, and replace missing values
improved formatting and clarified a few things
Mar
7
answered Transpose a file, and replace missing values
Feb
21
comment What does CRON=1 do?
@Bratchley - just to be nit picky ;) - What if there are scripts, etc. which are on unmounted media that you can't get to, or scripts you don't have write permission for? Then, a new name could involve a lot of possible consequences with very little upside. I know I get too used to having root/sudo permissions on my machine - so I can do anything - and then assume somewhat unjustified omnipotence.
Feb
16
comment Remap Return key in terminal to prevent accidental command on productions servers
I know several ways to do this in an X environment, but you usually don't have that on a server. I found this which might set you off in the right direction. bbs.archlinux.org/viewtopic.php?pid=1021839#p1021839
Feb
6
comment Pipes, how do data flow in a pipeline?
See also this question which shows how to use stdbuf which might also be helpful. unix.stackexchange.com/questions/182537/…
Jan
8
comment How to kill a runaway cat?
Wouldn't the killall -9 cat also kill any other cat instances that might still be doing good things in other process threads?
Jan
8
comment Autostart with AutostartCondition
I use KDE, so I'm sure I'm missing some fine points here, but: If it's a gui program, it needs the desktop environment to be already running. So why not just write an autostart script for it that your desktop will run when it starts. That script can test for any conditions you like and decide what to do. For example, see cyberciti.biz/tips/… . I don't get the gsettings part, but that may just be because I don't use that desktop.
Jan
8
comment How to write bash script to configure my displays when HDMI is plugged in or unplugged
Upon further research, it appears that automatic audio switching was not implemented because it was not clear how to determine which audio device a user would want to use. This can be implemented by a user with a custom udev rule, but I haven't figured out how yet. For now, I have a shell script tied to an icon on my taskbar which I just have to click to do it manually.
Dec
26
comment Switch to parent shell without logging out
If you are using a gui desktop, you can just open another terminal window or tab or even switch to another virtual console. If not, use screen as stated in one of the answers.
Dec
17
comment Get total duration of video files in a directory
Thanks, the following (maybe unformatted) works DUR=$(avprobe -loglevel quiet -show_format_entry duration "$1"); DUR=$(cut -d '.' -f 1 <<< "$DUR"); ((DUR_MIN=DUR/60)); echo "${DUR_MIN}" I truncated the fractional seconds to avoid processing a floating point value.