Next tag badge:
1057/400 score
79/80 answers
3 61 95
 Good Answer
~1.5m people reached

comment Lost file when renaming it
@amarillo You're right. Since the command ran without error, OP probably just clobbered whatever existing .dat file he had.
comment Extract value from XML
Can you provide a second sample input and output? Just as one cannot extrapolate a line from a single data point, we cannot tell what you need from a single example.
comment Delayed Expansion
If you read about how to write quines, like here, you would see that what you are looking for is simply printf, which a POSIX sh should have. What you call "delayed expansion" is merely string formatting.
comment Is there a way I can grep recursively over all the files in the current directory to find a pattern and then print it in order of high to low?
Sort does more things than you might be aware of, which you can learn more about by reading the man page. Try sort -t : -k 2,2n
comment Is there a way I can grep recursively over all the files in the current directory to find a pattern and then print it in order of high to low?
Have you tried the sort command?
comment Unexpected field expansion behavior by bash for loop
@JohnCarpenter The only thing for loops iterate over is words. It doesn't care whether those words were manually typed by someone or resulted from field splitting a normal variable or a bash array.
comment Can someone please explain this error I'm getting in my script
Put shopt extglob on the line before the cp command and post what it prints out.
comment How to call a script after every bash command
@PSkocik "prior to every command == after every command + at the beginning of your bash session" -- true for strict sequencing but no longer holds when time is considered. If you want something that depends on the time you hit the Enter key that is much harder to do.
comment How to wait for all spawned and backgrounded processes to finish in bash script
The wait and $! constructs are shell tools for controlling jobs / processes your shell spawns. In your description, the only process your shell spawns is BAR, and by your description, BAR exits immediately after spawning some opaque background stuff. Your shell can't see that background stuff BAR does, only BAR, so it doesn't even have any background jobs / processes to use wait / $! on. If you need a mechanism to know whether the internal background process spawned by BAR exit FOO1 worked, it has to come from BAR.
comment Recursive Function not Working
(a) You can't cd to non-directories. (b) Relative paths will stop working if you keep changing your current directory. Either go back to the previous directory or use absolute paths. (c) Don't use $(echo *), that's both broken and inefficient, just use */ (or "$PWD"/*/ for absolute paths).
comment How are parentheses interpreted at the command line?
@CMCDragonkai The $() is command substitution, the () is a subshell. Both of them run commands, the difference is what happens to the output. The names are much easier to search than the symbols. See also
comment how to echo $, & symbols correctly?
You shouldn't be looking at windows batch file information for help with bash. They are different things.
comment How to remove a single line from history?
@Moberg $num is a shell parameter (a.k.a. variable). I can see how my example would be confusing if you didn't know about shell parameter expansion, so I edited the code to use a concrete example instead.
comment Find -exec + vs find | xargs. Which one to choose?
I don't see how -0 is more of a pain than --delimiter "\n".
comment adding text to filename before extension
@SargeBorsch What do you need explained? My answer, the snippet in the question, and Doug's answer are only differ by a few characters, and Doug's answer explains even less than mine so I don't know what it is you want. If you just compare the difference in the two outputs in the question it should be trivially easy to figure out what they do. I can explain why my answer is preferable to Doug's. 1. I use printf with a format string instead of the less portable echo. 2. I use parameter expansion which is more efficient than calling an external binary (basename) for such a simple task.
comment What are the steps of this command using ; || and &&
@R0tten && and || are left-associative binary operators with equal precedence. The ; is not an operator at all but merely a simple separator, like a newline, and as such has the lowest "precedence". That should be enough to clear up any confusions you have.
comment Find files whose name is 4 characters long
Judging by the example given in the question, OP is looking at file names not contents.
comment Find files whose name is 4 characters long
@joeLovick In *nix platforms a newline is a single linefeed character.
comment Find files whose name is 4 characters long
@ColeJohnson It's not the best tool for the job. grep matches lines of text, but not all filenames are guaranteed to be single lines of text.
comment Need to Split the output in Row & Column
@user43791 You are right. I discovered the same and deleted my prior erroneous comment but it turns out you saw it anyways. After reviewing the awk grammar, I learned that the print statements do accept parentheses after all so carry on as you were.