I have a script that process a folder, and count the files in the mean time.  i=1 find tmp -type f | while read x do     i=$(($i + 1))    echo $i done echo $i   However, $i is always 1, how do I resolve this?
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?
Counting number of vertices of polygons and lines in QGIS? In QGIS, is there a way to count the number of vertices of polygons and lines in a given layer, and create a separate field containing these values?   I suspect it's a function somewhere in the field calculator but I can't find it. How does centrifugal force work? I've encountered a particular type of writing occasionally and it being, derp, in writing, it's hard to tell whether there's an accent behind it. The English used seems to me to be simply incorrect, but I can't help but feel that the following features are part of a dialect or a regional style of English. One of the most glaring (and grating) features is the substitution of &quot;saw&quot; with &quot;seen&quot;.  He seen him at the shop the other day. I seen that you were looking for... etc.  The use of &quot;away (to)&quot; is also peculiar, if not incorrect.  He was away to open the door when... He was away to get what he had asked for. etc.  I haven't come across these forms very often, and even then it was accompanied by otherwise mostly correct English, which is what makes me wonder what the hell. This is more intellectual curiosity than anything else. I have shown that if two $n\times n$ matrices $A$ and $B$ are invertible, then $AB$ is also invertible. I am having problems though with showing that $(AB)^{-1}=B^{-1} A^{-1}$. I thought of using their left-multiplication transformations but it seems that this is only associative and not commutative so I can reverse $L_A L_B$ I have looked in several different Fate games' rulebooks, including Fate Core, DFRPG, Atomic Robo, FAE, and Jadepunk, which all describe Boosts as temporary Aspects you get to invoke for free, one time, and which disappear after being invoked.  In the other "invoke for free" situation I'm aware of (on Aspects newly-created via the Create Advantage action), they aren't singled out as "temporary."  I looked in many books but I'm interested in Fate Core.  So I haven't been able to figure out whether Boosts need to be invoked immediately or they disappear, without having been invoked at all? I have long been confused about this notion. I know that for a statement within a single category, forming the dual statement is just reversing every arrows. But what about a statement concerning several categories and functors between them?   Mac Lane suggests reversing all arrows in all categories and leaving the functors invariant in his book "Categories for the working mathematician" (page 32), but it seems that Mac Lane himself doesn't always follow this discipline (when he states "the dual of Yoneda Theorem", he doesn't reverse the arrows in $\mathbf{Set}$ !) Can anyone give me a formal definition of "dualize a statement in category theory"? I am looking for an app that can monitor my C: (system) drive and find which program is creating a folder, with the rather generic name TEMP1\, on that drive.  I wouldn't mind if it could hook the creation of files too – as there a couple of files created as well (quite probably from another process). Google does not help me, as the names of those files are a bit generic too (not as TEMP1 though – dvmaccounts.ini and dvmexp.idx).   The problem is that every time I delete those, they are recreated on startup, so the utility I'm searching must start up on boot and also start fast. It should also be really clever, as my C: drive is huge. Let $X$ be a normed vector space.   Show that if a subsequence of a Cauchy sequence converges, then the whole sequence converges. Use the part 1 to show that $S = \{x\in X : \|x\| = 1\}$ is complete if and only if $X$ is Banach.     I have found the first part in a book, but I do not how to prove part 2. Thanx regards How do I extract a single chunk of bytes from within a file? Bold code in a question Frequently when I ask a question I have to include quite a bit of code for reference purposes.    It would be nice to be able to bold the important lines in the code.  For example this code:  &lt;DataTrigger Value="True"&gt;     &lt;DataTrigger.Binding&gt;         &lt;MultiBinding Converter="{StaticResource DisableWorkItemConverter}"&gt;             &lt;Binding ElementName="MainForm" Path="PickedWorkItemID"/&gt;             &lt;Binding Path="Id"/&gt;         &lt;/MultiBinding&gt;     &lt;/DataTrigger.Binding&gt;     &lt;Setter Property="IsEnabled" Value="False"/&gt;     &lt;Setter Property="IsSelected" Value="False"/&gt; &lt;/DataTrigger&gt;   Is not way long, but the important part (as seen in ) is the second to last line.  However, if I try to bold it, it ends up looking like this:  &lt;DataTrigger Value="True"&gt;     &lt;DataTrigger.Binding&gt;         &lt;MultiBinding Converter="{StaticResource DisableWorkItemConverter}"&gt;             &lt;Binding ElementName="MainForm" Path="PickedWorkItemID"/&gt;             &lt;Binding Path="Id"/&gt;         &lt;/MultiBinding&gt;     &lt;/DataTrigger.Binding&gt;     &lt;Setter Property="IsEnabled" Value="False"/&gt;     **&lt;Setter Property="IsSelected" Value="False"/&gt;** &lt;/DataTrigger&gt;   Not what I was going for.  It would be nice to be able to draw attention to specific lines of code when needed.    (One suggestion of a different color background sounds nice too (ie a yellow background to draw the eye to the relevant code.)  If there is some other way to bold in code please let me know. The topic which haunted me for two years until I gave up on it. But now I am doing engineering and this topic suddenly popped out of my textbook from nowhere. I seriously need to understand this topic because I wasn't able to do so in the past. I have read many book on 'energy' and it came to nothing. Maybe just because the many books I have read all said 'energy' is something which doesn't 'exist'! It is 'abstract'! It is just a number which represents the state or orientation of a system. But then I see so many examples that 'uses' energy to do 'work'. But the question here is that if anything doesn't exist in this universe, then how can the same thing be used to do something that exist?  My problem is that I didn't understood the topic 'energy' and all the other topics related to it (work, power etc.) Ubuntu not detecting second monitor I'm running Ubuntu 12.04 on a Lenovo x61s Thinkpad. As the screen's rather small and I want to do some video editing, I thought I'd plug in a monitor and use that. The monitor is Relisys JM777 (quite old).  When I plug it into my other computer, which is running Windows 7, it immediately mirrors the display; but when plugged into the Lenovo the monitor screen remains blank. The graphics card on the Lenovo is a "VGA compatible controller" according to SysInfo.   Anybody got any suggestions for getting this monitor to work? I'm quite new to Linux. I have put a bounty on , however I don't see it appear in the  (also not when I'm not logged in).  Why is this. Aren't all bounty questions supposed to be visible there? How to compare two TeX codes and mark differences with color I would like to find easy tool, which compares two TeX codes and generates a PDF file of the first code, in which the differences from the second code are marked by a given color. I use winedt 7.0 under windows 7.  I just noticed that latexdiff provides what I need. As far as I understand it is included in Miktex. Is there an interface (menu commands) in winedt 7.0, which allow to work with latexdiff ? Do Triggered effects stack? Is there a proof from the first principle that the Lagrangian L = T - V? Is there a proof from the first principle that for the Lagrangian $L$,    $$L = T\text{(kinetic energy)} - V\text{(potential energy)}$$  in classical mechanics? Assume that Cartesian coordinates are used. Among the combinations, $L = T - nV$, only $n=1$ works. Is there a fundamental reason for it?  On the other hand, the variational principle used in deriving the equations of motion, Euler-Lagrange equation, is general enough (can be used to to find the optimum of any parametrized integral) and does not specify the form of Lagrangian. I appreciate for anyone who gives the  answer, and if possible, the primary source (who published the answer first in the literature).      Notes added on Sept 22: - Both answers are correct as far as I can find. Both answerers were not sure about what I meant by the term I used: 'first principle'. I like to elaborate what I was thinking, not meant to be condescending or anything near to that. Please have a little understanding if the words I use are not well-thought of. - We do science by collecting facts, forming empirical laws, building a theory which generalizes the laws, then we go back to the lab and find if the generalization part can stand up to the verification. Newton's laws are close to the end of empirical laws, meaning that they are easily verified in the lab. These laws are not limited to gravity, but are used mostly under the condition of gravity. When we generalize and express them in Lagrangian or Hamiltonian, they can be used where Newton's laws cannot, for example, on electromagnetism, or any other forces unknown to us. Lagrangian or Hamiltonian and the derived equations of motion are generalizations and more on the theory side, relatively speaking; at least those are a little more theoretical than Newton's laws. We still go to lab to verify these generalizations, but it's somewhat harder to do so, like we have to use Large Hadron Collider. - But here is a new problem, as @Jerry Schirmer pointed out in his comment and I agreed. Lagrangian is great tool if we know its expression. If we don't, then we are at lost. Lagrangian is almost as useless as Newton's laws for a new mysterious force. It's almost as useless but not quite, because we can try and error. We have much better luck to try and error on Lagrangian than on equations of motion. - Oh, variational principle is a 'first principle' in my mind and is used to derive Euler-Lagrange equation. But variational principle does not give a clue about the explicit expression of Lagrangian. This is the point I'm driving at. This is why I'm looking for help, say, in Physics SE. If someone knew the reason why n=1 in L=T-nV, then we could use this reasoning to find out about a mysterious force. It looks like that someone is in the future. Nothing happens when I press "Submit" on duplicate suggestion For example, in . iPad won't turn on after a complete battery drain My iPad mini retina is out of warranty,  I forgot to plug in my iPad after the critical battery warning and it went some minutes following the warning. I was not worried because same thing had happened a few times before and iPad was perfectly okay after charging it. However, this time I remember seeing a flash of blue screen immediately after it went black. Then, I plugged it in an waited for a while and tried starting it. Ever since, it fails to start hanging on the apple logo with white background screen.   I tried to connect to my Mac but nothing showed up in iTunes. I am worried now. Can I troubleshoot this or is it broken and needing repair? How do I convert two lists into a dictionary? Dissolve (merge) polygons QGIS based on attribute values only when are adjacent