Reputation
24,513
Top tag
Next privilege 25,000 Rep.
Access to site analytics
Badges
3 59 94
Newest
 Enlightened
Impact
~1.3m people reached

22h
comment Delayed Expansion
I am confused where in my comment made you think I am talking about C. Quines are a universal concept that can be written in nearly all languages. printf works nearly identically in C and shell. The important part is understanding the concept of quines - once you do you can apply it to any language you are proficient with.
22h
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.
2d
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
2d
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?
2d
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.
Jan
20
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.
Jan
19
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.
Jan
15
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.
Jan
13
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).
Dec
7
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 unix.stackexchange.com/q/213530/9537
Sep
4
comment how to echo $, & symbols correctly?
You shouldn't be looking at windows batch file information for help with bash. They are different things.
Aug
26
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.
Jul
28
comment Find -exec + vs find | xargs. Which one to choose?
I don't see how -0 is more of a pain than --delimiter "\n".
Jun
23
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.
Jun
5
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.
Jun
4
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.
Jun
4
comment Find files whose name is 4 characters long
@joeLovick In *nix platforms a newline is a single linefeed character.
Jun
4
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.
Jun
2
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.
Jun
2
comment Need to Split the output in Row & Column
@NitinKapoor I added tabs to the output. Is that what you meant by rows and columns?