Reputation
689
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
5 11
Newest
 Civic Duty
Impact
~21k people reached

  • 0 posts edited
  • 0 helpful flags
  • 306 votes cast
Jun
28
awarded  Civic Duty
Jun
24
comment How can I combine values from two columns?
Wow! That makes a lot more sense (and shows me a bunch of things I need to learn more about.) In particular, I had never noticed the use of // to reuse the current pattern. That's the kind of thing you read over and forget until you run into an actual example. Thanks a lot. It made me laugh to see how much power could be packed into a miniscule command and how much it took to explain it.
Jun
20
comment How can I combine values from two columns?
I believe it works, but I can't parse it. Overall, you're setting up an addition for dc. The first pattern makes sense. I think it matches the date and trailing blanks, but I don't get what putting that inside the character class brackets ([&]) does. It would be great if you would spell this one out.
Jun
20
comment Download a webpage by putting everything it needs in a dedicated directory?
Here's a guess as to what's going on. As you know, wget -p will download what is needed for the webpage to display offline - like its source code. References to external files are embedded in the webpage source. If they were downloaded in another directory structure, then all those references would have to be modified to reflect that. When a browser looks at a webpage, it renders it into a displayable whole - like compiled code. It has used the files and has the result. It is in a very different situation than wget is, so it may be able to save the result rather than the initial input.
Jun
13
comment manipulate multiple windows simultaneously
No answer, but I put in an informal feature request for something like this on a KDE list a long time ago (with no responses). I sometimes run multiple torrents using Transmission and it allows you to open a window following each one. I wanted to be able to minimize/move/close the whole lot of them at once with a window group. The main deal was that I wanted to be able to do things to them while keeping who was on top of who the same.
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