I was asked to create command which generates one word in terminal, if internet connection is absense, and another one, if it present. For doing that it seems that I need "if" and "else" syntaxis. Is it possible to provide such syntaxis in terminal?
I am trying to pull logs and doing few others things directly. written a small line BASH but not working. I am sure thats with IF Condition.    sed -rne '/21:25:07/,/21:50:07/ p'  server.log.2015-04-21 &gt; /tmp/filename.log ; du -sh  /tmp/filename.log ;  if [`du -sh  /tmp/filename.log` -gt 0] then gzip /tmp/filename.log ;
In a photoelectric effect we remove electrons from a metal using high energy photons, the work function is the minimal energy required for this effect.  My question is why doesnt the work fucntion depended on time? The more electrons we take out from the metal, the more ionized it becomes (if we remove a lot of negative charge, it will turn positive), and as a result we would expect to need more energy for this effect (the possitive charge of the metal would make it harder to remove the remaining electrons).  Why does the work function remains constant no matter how much electrons we take out? New UI encourages askers to confirm or dispute duplicate votes , the banner shown to askers whose questions have attracted at least one duplicate close vote has a couple of new options:    If the author clicks the first button, they're shown a confirmation that clarifies the results of this action somewhat:    If they click "Ok", the question is instantly closed:    If, instead, they edit, they'll be offered this guidance:    ...and once an edit is submitted the choice will go away until another duplicate close-vote is cast.   In just the past day, 80 questions  network-wide have been closed in response to confirmation from the asker; edits by askers are up significantly as well.   We'll be monitoring the results to see if further adjustments are needed. A few open questions surrounding this change include:    Perhaps if the number of votes is below some threshold?   I'm posting this separately from  to allow room for discussion and . How many integers between $1$ and $10^4$ contain exactly one $8$ and one $9$? I have this problem: How many integers between $1$ and $10^4$ contain exactly one $8$ and one $9$?, but i dont know if $18, 19, 28, 29...$ serve, else it could be $8$ y $9 = 2$ numbers, help please. As per the title, what is this new feature? Is there a way to switch the mesh selection mode by a shortcut? Proof that any self-complementary graph has to have $4k$ or $4k+1$ vertex, for some $k \in \mathbb N$ Find the ratio of $\frac{\int_{0}^{1} \left(1-x^{50}\right)^{100} dx}{\int_{0}^{1} \left(1-x^{50}\right)^{101} dx}$ $$I_1=\int_{0}^{1} \left(1-x^{50}\right)^{100} dx$$ and $$I_2=\int_{0}^{1} \left(1-x^{50}\right)^{101} dx$$ Then find $\frac{I_1}{I_2}$  I tried by subtracting $I_1$ and $I_2$   $$I_1-I_2=\int_{0}^{1}\left(1-x^{50}\right)^{100}\left(1-(1-x^{50}\right))dx$$ so  $$I_1-I_2=\int_{0}^{1} \left(1-x^{50}\right)^{100} x^{50} dx$$ Now using Integration by Parts we get  $$I_1-I_2= \left(1-x^{50}\right)^{100} \times \frac{x^{51}}{51}\bigg|_{0}^{1} -\int_{0}^{1} 100 \left(1-x^{50}\right)^{99} \times -50 x^{49} \times \frac{x^{51}}{51} dx$$  So $$I_1-I_2=\frac{5050}{51} \times \int_{0}^{1}\left(1-x^{50}\right)^{99} x^{100} dx$$  Now $x^{100}=\left(1-x^{50}\right)^2-(1-x^{50}-x^{50})$ so  $$\frac{51}{5050}(I_1-I_2)=\int_{0}^{1} \left(1-x^{50}\right)^{99} \times \left(\left(1-x^{50}\right)^2-(1-x^{50})+x^{50}\right)dx=I_2-I_1+\int_{0}^{1} \left(1-x^{50}\right)^{99} x^{50} dx$$  Need a hint to proceed further. Transform the NFSA with transition table  $$\begin{array}{ccc} X&amp;a&amp;b\\ A&amp;\{\}&amp;\{F\}\\ B&amp;\{\}&amp;\{\}\\ F&amp;\{\}&amp;\{A,S\}\\ S&amp;\{F\}&amp;\{A,F\} \end{array}$$  and starting state $S$ inta a DFSA and give the transition table of that DFSA. Place the letter $X$ (uppercase) in the top left corner of the matrix. Your states in the first column and inputs in the first row can be in the order of your choice.  The question then offers a $7\times 3$ matrix to be filled in.  Unsure how to transform the NFSA with transition table.  This is my answer but it is incorrect.  $$\begin{array}{ccc} X&amp;a&amp;b\\ \{S\}&amp;\{F\}&amp;\{A,F\}\\ \{F\}&amp;\{\}&amp;\{A,S\}\\ \{A\}&amp;\{\}&amp;\{F\}\\ \{A,F\}&amp;\{\}&amp;\{A,F,S\}\\ \{A,S\}&amp;\{F\}&amp;\{A,F\}\\ \{A,F,S\}&amp;\{F\}&amp;\{A,F,S\} \end{array}$$ Get text from pressed button How does the Comma Operator work How does the comma operator work in C++?  For instance, if I do:  a = b, c;     Does a end up equaling b or c?   (Yes, I know this is easy to test - just documenting on here for someone to find the answer quickly.)  Update:  This question has exposed a nuance when using the comma operator.  Just to document this:  a = b, c;    // a is set to the value of b!  a = (b, c);  // a is set to the value of c!   This question was actually inspired by a typo in code.  What was intended to be  a = b; c = d;   Turned into  a = b,    //  &lt;-  Note comma typo! c = d; We've all wanted to express certain questions, rhetorical or not, with annoyance, excitement, surprise, frustration and so on. What better way than with both a question mark (?) and an exclamation mark (!), right? I've seen two ways of punctuating such questions:  Where is this place?!    Who do you think you are!?  (Things like ?!?, !?!, ?????!!!!!, ??!?!!?!?!!??, etc are irrelevant here.) Which is the proper way to order the two symbols? Or does each of the above two have a distinct and grammatically correct meaning? Or is the interrobang (‽) the clear winner here? ;) Working with large images and transform in the VSE Floating Objects and Weight The Situation:  A ball is placed in a beaker filled with water and floats. It is also attached to the bottom of the beaker via a string.   The Question:  The ball is attached to the beaker, thus making the ball and beaker (and string included) a system. However, it is floating. Does the ball add to the weight of the beaker? I was reading a blogpost here:  () One thing that threw me off was that after the first four large displayed equations, there is the statement &quot;it is sufficient to prove that if the theorem holds for $n=m+1$, then it holds for $n=m$.&quot; How is this type of induction valid? I browsed around for things like backward induction, reverse induction, and Cauchy induction, but couldn't find a justification for how this is valid. With the usual forward induction of verifying a base case and proving $P(n)\implies P(n+1)$, it's easy to intuitively understand how induction will show a property holds for all natural numbers (or at least starting at the base case). But with this reverse induction, it seems to me that if you prove $P(m+1)\implies P(m)$, then if you were able to verify a specific case like $P(15)$, then you would only know it's true for numbers up to $15$. How does it actually prove the property for all naturals? Suppose I have 30 numbers that vary between 0 and 1.0 and which sum to 1.0.  The mean is obviously 0.033.  A client wants these scaled to lie between 0 and 1.0 but to have a mean of 0.5.  By the way, I'll probably have to do this for any set of numbers (positive, negative, outside the range 0 - 1) so that they lie in the range 0 - 1 and have a mean 0.5.  Any suggestions? Integrating $\int^{\infty}_0 e^{-x^2}\,dx$ using Feynman's parametrization trick How can I manually interpolate string escapes in a Perl string? Divergence of $\sum_{n=1}^{\infty} \frac{1}{2+i^n}$? I notice that,  $i^n = i, \quad if \text{ } n \equiv \text{ } 1 \text{ } mod \text{ } 4$  $i^n = -1, \quad if \text{ }n \equiv \text{ } 2 \text{ } mod \text{ } 4$  $i^n = -i, \quad if \text{ }n \equiv \text{ } 3 \text{ } mod \text{ } 4$  $i^n = 1, \quad if \text{ } n \equiv \text{ } 0 \text{ } mod \text{ } 4$  so the series $\sum_{n=1}^{\infty} \frac{1}{2+i^n}$ seems to be an alternating series that does not converge to any point in the complex plane. Is there a rigorous way to prove this divergence? How would you write a proof to this divergence or convergence (if I am wrong)?  Thanks! Git command to show which specific files are ignored by .gitignore I am getting my feet wet with Git and have the following issue:  My project source tree:  / | +--src/ +----refs/ +----... | +--vendor/ +----...   I have code (currently MEF) in my vendor branch that I will compile there and then move the references into /src/refs which is where the project picks them up from.  My issue is that I have my .gitignore set to ignore *.dll and *.pdb.  I can do a git add -f bar.dll to force the addition of the ignored file which is ok, the problem is I can not figure out to list what files exist that are ignored.  I want to list the ignored files to make sure that I don't forget to add them.  I have read the man page on git ls-files and can not make it work. It seems to me that git ls-files --exclude-standard -i should do what I want.  What am I missing? One of my coworkers has provided me with a Bash syntax that I am unfamiliar with.  My Google foo has failed me on figuring out what it does and why/when I should use it.    The command that he sent me was of this form:  someVariable=something command   Initially, I thought that this was equivalent to the following:   someVariable=something ; command   Or  someVariable=something  command   But this doesn't appear to the be case.  Examples:   [Jan-03 11:26][~]$ # Look at the environment variable BAZ. It is currently empty [Jan-03 11:26][~]$ echo $BAZ  [Jan-03 11:27][~]$ # Try running a command of the same format     [Jan-03 11:27][~]$ BAZ=jake echo $BAZ  [Jan-03 11:27][~]$     [Jan-03 11:27][~]$ # Now, echo BAZ again. It is still empty:     [Jan-03 11:27][~]$ echo $BAZ  [Jan-03 11:27][~]$     [Jan-03 11:28][~]$     [Jan-03 11:28][~]$ # If we add a semi-colon to the command, we get dramatically different results: [Jan-03 11:28][~]$ BAZ=jake ; echo $BAZ jake [Jan-03 11:28][~]$ [Jan-03 11:28][~]$ # And we can see that the variable is actually set: [Jan-03 11:29][~]$ echo $BAZ jake [Jan-03 11:29][~]$   What does this syntax do?  What happens to the variable that has been set?  Why does this work?