I am having a hard time tracking down the reason my 'boolean' flag variable won't stay false when a test fails inside a while loop.  The script involves a few loops but essentially it is intended to play two random albums every morning when it is triggered by cron. I used to have a simple one-liner script that selected two albums but I wanted to blacklist any albums that I didn't want playing (i.e. christmas music albums).  To do this, I had it read a wakeUp_blacklist.txt file with the names of albums I didn't want to hear so it can reject any matches. This compares the blacklisted albums line-by-line with one randomly selected album and tests for a match. If a match is found, it flags the match as a failure (pass = false) and SHOULD loop back and select a different album. For some reason, as soon as the execution exits the read | while loop, the flag switches back to true and so another album is never selected!  Here is my code and an example output:  #!/bin/bash  wd="/media/External1/albums"  pass="false" for ((i=0; i&lt;=1; i++)); do     while [ "$pass" == "false" ]; do         album=`ls -d "$wd"/*/*/ | sort -R | tail -n 1`         echo "album selected:"         echo "$album"         pass="true"         echo "pass reset; pass=$pass"         cat "$wd/wakeUp_blacklist.txt" | while read black; do             echo "pass check 2:$pass"             echo "black: $wd/$black"             if [ "$album" == "$wd/$black" ] || [ "$album\n" == "$albums" ]; then                 pass="false"                 echo "test failed; pass=$pass"             fi             echo "pass check 1:$pass"         done         echo "Blacklist check complete; pass=$pass" #Why is it true again?!     done     pass="false"     albums="$albums$album\n"     echo "album assigned:"     echo "$album" done  echo echo  for album in "$albums"; do #    play "$album*"      echo -e "$album" #List album names rather than actually play them done   So, if I run this a few times, it will eventually chose one of the blacklisted albums and give output that looks like:  album selected: /media/External1/albums/Adele/21/ pass reset; pass=true pass check 2:true black: /media/External1/albums/Vince_Guaraldi_Trio/A_Charlie_Brown_Christmas/ pass check 1:true pass check 2:true black: /media/External1/albums/Sound_Inventions/Stille_Nacht-_A_German_Christmas/ pass check 1:true Blacklist check complete; pass=true album assigned: /media/External1/albums/Adele/21/ album selected: /media/External1/albums/Sound_Inventions/Stille_Nacht-_A_German_Christmas/ pass reset; pass=true pass check 2:true black: /media/External1/albums/Vince_Guaraldi_Trio/A_Charlie_Brown_Christmas/ pass check 1:true pass check 2:true black: /media/External1/albums/Sound_Inventions/Stille_Nacht-_A_German_Christmas/ test failed; pass=false pass check 1:false Blacklist check complete; pass=true album assigned: /media/External1/albums/Sound_Inventions/Stille_Nacht-_A_German_Christmas/   /media/External1/albums/Adele/21/ /media/External1/albums/Sound_Inventions/Stille_Nacht-_A_German_Christmas/   You can see that towards the end, when the blacklist entry is a match for the selected album (German_Christmas) the test fails, the pass variable is false but the first output that checks pass value outside the read | while loop shows it being true again!  I understand that my script may not be as efficient as possible yet but I want to understand what is happening here before I move on. Any suggestions?
Why do I get different values for $x from the snippets below?  #!/bin/bash  x=1 echo fred &gt; junk ; while read var ; do x=55 ; done &lt; junk echo x=$x  #    x=55 .. I'd expect this result  x=1 cat junk | while read var ; do x=55 ; done echo x=$x  #    x=1 .. but why?  x=1 echo fred | while read var ; do x=55 ; done echo x=$x  #    x=1  .. but why?
What happens if light/particles exceeded the speed of light for a particular medium? Say I want to copy the contents of a directory excluding files and folders whose names contain the word 'Music'.  cp [exclude-matches] *Music* /target_directory   What should go in place of [exclude-matches] to accomplish this? Proving the snake lemma without a diagram chase Suppose we have two short exact sequences in an abelian category $$0 \to A \mathrel{\overset{f}{\to}} B \mathrel{\overset{g}{\to}} C \to 0 $$ $$0 \to A&#39; \mathrel{\overset{f&#39;}{\to}} B&#39; \mathrel{\overset{g&#39;}{\to}} C&#39; \to 0 $$ and morphisms $a : A \to A&#39;, b : B \to B&#39;, c : C \to C&#39;$ making the obvious diagram commute. The snake lemma states that there is then an exact sequence $$0 \to \ker a \to \ker b \to \ker c \to \operatorname{coker} a \to \operatorname{coker} b \to \operatorname{coker} c \to 0$$ where the morphisms between the kernels are induced by $f$ and $g$ while the maps between the cokernels are induced by $f&#39;$ and $g&#39;$.  It is not hard to show that the morphisms induced by $f, g, f&#39;, g&#39;$ exist, are unique, and that the sequence is exact at $\ker a, \ker b, \operatorname{coker} b, \operatorname{coker} c$. With the use of a somewhat large diagram shown , we can even construct the connecting morphism $d : \ker c \to \operatorname{coker} a$. However, I'm stuck showing exactness at $\ker c$ and $\operatorname{coker} a$. I thought Freyd might have had an element-free proof in his book, but it turns out he proves it by diagram chasing and invoking the Mitchell embedding theorem [pp. 98–99]. Is there a direct proof? How can Zeno's dichotomy paradox be disproved using mathematics? A brief description of the paradox taken from :     Suppose Sam wants to catch a stationary bus. Before he can get there, he must get halfway there. Before he can get halfway there, he must get a quarter of the way there. Before traveling a quarter, he must travel one-eighth; before an eighth, one-sixteenth; and so on.      This description requires one to complete an infinite number of tasks, which Zeno maintains is an impossibility. This sequence also presents a second problem in that it contains no first distance to run, for any possible (finite) first distance could be divided in half, and hence would not be first after all. Hence, the trip cannot even begin.      The paradoxical conclusion then would be that travel over any finite   distance can neither be completed nor begun, and so all motion must be   an illusion.   How can this be disproved using math, as obviously we can all move a walk from one place to another? How to execute multiple statements in a MATLAB anonymous function? I'd like to do something like this:  &gt;&gt; foo = @() functionCall1() functionCall2()   So that when I said:  &gt;&gt; foo()   It would execute functionCall1() and then execute functionCall2().  (I feel that I need something like the )  EDIT:  functionCall1 and functionCall2 are not necessarily functions that return values. I am trying to represent trade flows on a world map where the size and direction of arrows indicate the exports/imports of a given country.  This type of map is commonly found in magazines and newspapers. However, I find it extremely difficult to make.   Is there any function in ArcGIS for Desktop or any free software that would help me in making it? Based on Logman dictionary:       happen to do something: if you happen to do something, you do it by chance.   for example take a look at these examples:     They happen to be unemployed at the time. I happen to have a degree in computer science.    So based on the definition of the happen to do something, first one means they are probably unemployed at the time. and the second one means I probably have a degree in computer science.     Am I right? How prove this two symmetric matrices $AB=0$ Let $A,B$ be real symmetric matrices, and for any $n\in \Bbb N^{+}$, and for all $x,y\in \Bbb R$, we have $$tr(xA+yB)^n=x^ntr(A^n)+y^ntr(B^n).$$  Show that $AB=0$.  My try:since $$(xA+yB)^n=x^nA^n+\binom{n}{1}x^{n-1}A^{n-1}yB+\cdots+\binom{n}{n-1}xA(yB)^{n-1}+y^nB^n$$ so $$tr\left(x^nA^n+\binom{n}{1}x^{n-1}A^{n-1}yB+\cdots+\binom{n}{n-1}xA(yB)^{n-1}+y^nB^n\right)=x^ntr(A^n)+y^ntr(B^n)$$  then  $$tr\left(\binom{n}{1}x^{n-1}A^{n-1}yB+\cdots+\binom{n}{n-1}xA(yB)^{n-1}\right)=0$$ so $$\binom{n}{1}x^{n-1}ytr(A^{n-1}B)+\cdots+\binom{n}{n-1}xy^{n-1}tr(AB^{n-1})=0$$ then I can't  I found this is a nice result, maybe this is an odd problem, and I can't solve it. Thank you. I think I have found the final answer $\left(4 \left[\frac{2t \cosh(4t) - \sinh(4t)}{t^2}\right]\right)$ but need to verify it. The other day I was trying to download something for Minecraft and it involved my bin folder. So I was looking for it and couldn't find it. I then thought that I might have accidentally deleted it, but didn't find it in the trash. I have no idea how to get the bin folder back with all the Minecraft binary files in them. How is the default user avatar generated? Variance of sample variance? What is the variance of the sample variance? In other words I am looking for $\mathrm{Var}(S^2)$.  I have started by expanding out $\mathrm{Var}(S^2)$ into $E(S^4) - [E(S^2)]^2$  I know that $[E(S^2)]^2$ is $\sigma$ to the power of 4. And that is as far as I got. Trying to understand what happens with a brokerage firm's customers when it goes bankrupt (case of study: Lehman Brothers) I'm trying to understand how secure it is to own mutual funds/ETFs, not in terms of market volatility etc., but in terms of judicial security (i.e. what happens to your holdings if the firm goes bankrupt). To understand it, I have read this article about the bankruptcy of Lehman Brothers:  Note: From now on, I'm always referring to investors who own funds/ETFs managed by Lehman Brothers, not by investors who invested in Lehman Brothers or subprime mortgages (e.g. S&amp;P 500 ETF investors). From the above article, what I have understood is that the funds/ETFs managed by Lehman Bros. were shifted to other brokerage firms to be managed by them. Is this what actually happened? Still, what happens with the investors if, hypothetically, no brokerage firm in the world wants to manage these financial products? How do you concatenate characters in java? Concatenating strings would only require a + between the strings, but concatenating chars using + will change the value of the char into ascii and hence giving a numerical output. I want to do System.out.println(char1+char2+char3... and create a String word like this.  I could do   System.out.print(char1); System.out.print(char2); System.out.print(char3);   But, this will only get me the characters in 1 line. I need it as a string. Any help would be appreciated.  Thanks What should the standard spelling be - British or US? I just saw someone edit the title of  question to  the spelling from favourite (The British spelling) to favorite (The US-English spelling).  Does SOFU have an accepted standard on language and spelling? Which is it? Why is it string.join(list) instead of list.join(string)? I think I'm being the victim of a bug here. Sometimes while I'm working (I still don't know why), my network traffic goes up to 200 KB/s and stays that way, even tough I'm not doing anything internet-related.   This sometimes happens to me with the CPU usage. When it does, I just run a top command to find out which process is responsible and then kill it. Problem is: I have no way of knowing which process is responsible for my high network usage. Both the resource monitor and the top command only tell me my total network usage, neither of them tells me process specific network info.  I've found questions here about monitoring total bandwidth usage, but, as I mentioned, that's not what I need. Is there another command I can use to find out which process is getting out of hand?  The command iftop gives results that disagree entirely with the information reported by System Monitor. While the latter claims there's high network traffic, the former claims there's barely 1 KB/s.  I've already tried killing all the obvious ones (Firefox, update-manager, Pidgin, etc) with no luck. So far, restarting the machine is the only way I found of getting rid of the issue. How to show that $|D_{2n}| = 2n$ via the presentation? Does Dim Light created by an effect override Bright Light in an area? Two examples.     A silvery beam of pale light shines down in a 5-foot-radius, 40-foot-high cylinder centered on a point within range. Until the spell ends, dim light fills the cylinder.      —Moonbeam, Player's Handbook, pg. 261        You create up to four torch-sized lights within range, [...] each light sheds dim light in a 10-foot radius.      —Dancing Lights, Player's Handbook, pg. 230   Now consider that each of these spells are cast on a bright day, obviously covered by Bright Light, as the game understands it.   Do these spells change the Bright Light within the area affected by them into Dim Light? Is the behavior different between Moonbeam ("Dim Light fills the cylinder") and Dancing Lights ("each light sheds dim light"), or do both of them behave the same? Show for prime numbers of the form $p=4n+1$,  $x=(2n)!$ solves the congruence $x^2\equiv-1 \pmod p$. $p$ is therefore not a gaussian prime.