Reputation
684
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
4 11
Newest
 Yearling
Impact
~19k people reached

  • 0 posts edited
  • 0 helpful flags
  • 267 votes cast
May
23
comment Prepare answers for questions of a command
+1 because I didn't know autoexpect existed and had figured that the expect learning curve was too steep for me to bother with. I'll take another look.
May
9
comment Why is my Bash script returning a syntax error?
Since it is generally recommended that the output of ls should not be used in scripts, I tried to figure out how to do this with find. I got as far as find . -maxdepth 1 -type f -printf '%c\t%f\n' -name '*', but the date is still hard to sort. It's not in epoch format yet. The tab is for use later with cut after sorting. AFAIK, the answer above (and all the others based on using ls) will potentially return directory names as well as file names - which might cause unexpected results with a command which expects to see a regular file.
May
8
comment Identify alias for the command typed
bash also has a read command which may be used to get input which is not subjected to any of it's many expansions. It may be possible to use that instead of an external program such as AutoKey, but it can get fairly tricky because using what you have read in can often expose part or all of it to expansions.
May
7
awarded  Yearling
May
7
comment Identify alias for the command typed
That looks really interesting! However, man bash says ALIASES Aliases allow a string to be substituted for a word when it is used as the first word of a simple command. which means there can be other stuff after the alias on the command line. If I read your code correctly, it would fail to match an alias for a command line with anything after the alias. So, the approach is great, but it may need some additional code to make sure you're just matching the alias and not the whole line.
May
3
comment What are the differences between xdotool and xautomation?
I also use xdotool for simple things (whenever I need something that AutoKey won't do) and wasn't aware of xautomation. Just glancing at the docs, the biggest difference is that xautomation includes tools for "looking" at the gui screen and xdotool does not. I'm going to look into it further because I need that capability.
May
3
revised Identify alias for the command typed
improved formatting
May
3
answered Identify alias for the command typed
May
3
comment Identify alias for the command typed
It would be a stretch, but if something like this was implemented as part of an AutoKey macro, the macro could then emit the original command as if the user had retyped it. That might work - eliminating the problems from the previous comment. While this might be instructive, you wouldn't want to leave anything like this running on a regular basis. It would be more of a diagnostic/educational tool for the operator.
May
3
comment Identify alias for the command typed
It might take a bit of coding, but, at least conceptually, it wouldn't be too hard to write a script which greps the output of the alias command for its first few arguments (the command to be executed), prints a reminder if it gets a match, and then runs its arguments with an eval. The tricky part would be that if the command to be executed runs in a subshell, its side effects would be lost to the calling shell. Built-ins might also be a problem. So, a basic implementation would be pretty easy, but one that actually works correctly, would be more difficult.
Apr
26
comment Transpose a file, and replace missing values
Nice piece of code! I had to read it a couple of times to see what it's doing. The line where you just name array elements to create them without assigning values to them took a moment to figure out. Interesting way to save the names. Looks like it does exactly what the OP requested.
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 how to get rsync to link identical files with --link-dest option if an old file already exists? [SOLVED]
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