I my code I have while cycle which reads from file: teams=() status=() novy=true j=0 k=0  while read line; do    name=$( echo &quot;$line&quot; | cut -d &quot;:&quot; -f 1 - )       for i in &quot;${teams[@]}&quot;; do     if [ &quot;$i&quot; = &quot;$name&quot; ]; then       novy=false              c=$( echo &quot;$line&quot; | cut -d &quot;:&quot; -f 3 - )       status[$k]=&quot;${status[$k]}+$c&quot;              break     fi     k=$(( k+1 ))     novy=true   done      if &quot;$novy&quot;; then     teams[$j]=&quot;$name&quot;     status[$j]=$( echo &quot;$line&quot; | cut -d &quot;:&quot; -f 3 - )     j=$(( j + 1 ))      novy=false   fi      k=0  done &lt; ms.txt  But now I want to modify input ms.txt so I tried this: input=$( cat ms.txt )    some modifiations of input (by echo &quot;$input&quot; I verified that the input is in right form)  echo &quot;$input&quot; | while read line; do    name=$( echo &quot;$line&quot; | cut -d &quot;:&quot; -f 1 - )       for i in &quot;${teams[@]}&quot;; do     if [ &quot;$i&quot; = &quot;$name&quot; ]; then       novy=false              c=$( echo &quot;$line&quot; | cut -d &quot;:&quot; -f 3 - )       status[$k]=&quot;${status[$k]}+$c&quot;              break     fi     k=$(( k+1 ))     novy=true   done      if &quot;$novy&quot;; then     teams[$j]=&quot;$name&quot;     status[$j]=$( echo &quot;$line&quot; | cut -d &quot;:&quot; -f 3 - )     j=$(( j + 1 ))      novy=false   fi      k=0  done  But now the code doesn't work, I don't know why. The while cycle doesn't read the input same as before and it prints some errors.
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?
How to convert an MKV to AVI with minimal loss To convert an MKV to AVI, I do two things. The first thing I do is this:  ffmpeg -i filename.mkv -vcodec copy -acodec copy output.avi   or this:  ffmpeg -i filename.mkv -sameq -acodec copy output.avi   Either of these will convert the MKV to an AVI, but the problem is that the video does not play smoothly for some reason. That's fine though, because if I do one more thing it gets fixed:  ffmpeg -i output.avi -vcodec mpeg4 -b 4000k -acodec mp2 -ab 320k converted.avi   After I do this then the file plays without problem. I had success doing it this way for one file, but then I tried it on another file, and there is a slight, but noticeable loss in video quality. This is the output I get when doing the second step:  FFmpeg version 0.6.1, Copyright (c) 2000-2010 the FFmpeg developers   built on Dec 29 2010 18:02:10 with gcc 4.2.1 (Apple Inc. build 5664)   configuration:    libavutil     50.15. 1 / 50.15. 1   libavcodec    52.72. 2 / 52.72. 2   libavformat   52.64. 2 / 52.64. 2   libavdevice   52. 2. 0 / 52. 2. 0   libswscale     0.11. 0 /  0.11. 0  Seems stream 0 codec frame rate differs from container frame rate: 359.00 (359/1) -&gt; 29.92 (359/12) Input #0, avi, from 'output.avi':   Metadata:     ISFT            : Lavf52.64.2   Duration: 00:04:17.21, start: 0.000000, bitrate: 3074 kb/s     Stream #0.0: Video: mpeg4, yuv420p, 704x480 [PAR 229:189 DAR 5038:2835], 29.92 fps, 29.92 tbr, 29.92 tbn, 359 tbc     Stream #0.1: Audio: vorbis, 48000 Hz, stereo, s16 Output #0, avi, to 'converted.avi':   Metadata:     ISFT            : Lavf52.64.2     Stream #0.0: Video: mpeg4, yuv420p, 704x480 [PAR 229:189 DAR 5038:2835], q=2-31, 4000 kb/s, 29.92 tbn, 29.92 tbc     Stream #0.1: Audio: mp2, 48000 Hz, stereo, s16, 320 kb/s Stream mapping:   Stream #0.0 -&gt; #0.0   Stream #0.1 -&gt; #0.1   I just used arbitrarily large settings on the second step and it worked nicely before but not in this case. What settings should I use? How to create a desktop shortcut in Unity? Is there an easy way to create a desktop shortcut for an application in Unity? The ability to right click or drag and drop icons to the desktop in Unity does not seem to be there. The reason that I ask is because this is happening to LiDAR, and I am inclined to use lidar because it is easier to read. Let $G$ be a lie group with lie algebra $\frak{g}$. Let $Aut(\frak g)$ be the automorphism group of $\frak{g}$.   Its clear to me that $Aut(\frak{g})$ $\subset GL(\frak{g})$ since any automorphism of $\frak{g}$ is also a linear transformation. Now i have several questions:   How do i prove that $Aut(\frak{g})$ is actually a lie subgroup of $GL(\frak{g})$? I've tried playing with actions to realize $Aut(\frak g)$ as an orbit or an isotropy subgroup but nothing worked out... Say $H \subset G$ is an abstract subgroup (not necessarily lie). Are the following statements equivalent?   $$\{T_e H \text{  is closed under the lie bracket of } \frak{g} \}$$  $$ \{H \text{is a lie subgroup of } G\}$$   How does the lie algebra of $Aut(\frak g)$ look like? When does $Aut(\frak g)$ $= G$? what does $Aut(\frak g)$ tell me about $G$? How do I print an IFrame from javascript in Safari/Chrome Can someone please help me out with printing the contents of an IFrame via a javascript call in Safari/Chrome.  This works in firefox:  $('#' + id)[0].focus(); $('#' + id)[0].contentWindow.print();   this works in IE:  window.frames[id].focus(); window.frames[id].print();   But I can't get anything to work in Safari/Chrome.  Thanks  Andrew When should comments be flagged/deleted on per-site metas? We all know , but that guidance is, naturally, geared toward main sites, where we want to keep things clean and focused.  Meta, on the other hand, is a site's "second place", with some different rules and conventions.  For example, questions on main sites can be closed as primarily-opinion-based, but meta is all about opinions.  There's a "discussion" tag and such questions collect many opinions.  Meta is different.  Occasionally I see comment flags on metas and I'm never sure what to do with them.  Setting aside things that are blatantly offensive or spam (that's a no-brainer), is there such a thing as "too chatty" or a comment discussion that should be moved to chat on meta?  I am very conservative in deleting things on per-site metas (except on  posts, which like main should stay focused).  Are there any guidelines specific to per-site metas?  I'm specifying per-site metas and not MSE because MSE seems to have conventions that fall somewhere between "main site" and "per-site meta".  If the answer is the same for all metas then great, but I don't want to assume it'll be the same. Question list on profile page not vertically aligned There's something wrong with the vertical alignment on the :   (click to enlarge)  On the , which uses a similar list but without the Favorite column, the vertical alignment is correct.  (Tested in the latest Firefox, Safari and Chrome on macOS Catalina.) Numbering of appendices in the backmatter of a book I'm using the standard book class. If I write  \documentclass{book}  \begin{document}  \frontmatter \tableofcontents  \mainmatter \chapter{foo} \section{Donald}  \backmatter \chapter{bar} \section{Mickey}  \end{document}   I expect to have chapter bar numbered as appendix A and section Mickey as A.1. Instead chapter bar is not numbered and section Mickey is 1.2, following section Donald. If I insert the appendix command to obtain  \documentclass{book}  \begin{document}  \frontmatter \tableofcontents  \mainmatter \chapter{foo} \section{Donald}  \backmatter \appendix \chapter{bar} \section{Mickey}  \end{document}   then chapter bar is unnumbered and section Mickey is numbered as .1.  What am I doing wrong? Why do clocks measure arc-length? Apologies in advance for the long question.  My understanding is that in GR, massive observers move along timelike curves $x^\mu(\lambda)$, and if an observer moves from point $x^\mu(\lambda_a)$ to $x^\mu(\lambda_b)$, then his clock will measure that an amount of time $t_{ba}$ given by the curve's arc length; $$   t_{ba} = \int_{\lambda_a}^{\lambda_b}d\lambda \sqrt{-g_{\mu\nu}(x(\lambda))\dot x^\mu(\lambda)\dot x^\nu(\lambda)} $$ will have elapsed where $g_{\mu\nu}$ is a metric on spacetime with signature $(-,+,+,+)$.    Why is this so?     Here is how I would attempt to justify this fact in special relativity with $g_{\mu\nu} = \eta_{\mu\nu}$.  Consider an inertial observer $O$ in $\mathbb R^{3,1}$, and suppose that this observer sees a clock, which I'll call observer $O'$ moving around on a curve $x^\mu(\lambda)$.  If $O'$ were also an inertial observer, then given any event with coordinates $x^\mu$ as measured by $O$, observer $O'$ would measure the coordinates of the event to be $x'^\mu = \Lambda^\mu_{\phantom\mu\nu} x^\nu + x_0^\mu$ for some Lorentz transformation $\Lambda$.  If $O'$ is not inertial, then this is no longer true, and there is some more complicated family of transformations, say $T_\lambda$ between events as seen by both observers.  I would argue, however, that if we were to partition the interval $[\lambda_a, \lambda_b]$ into a large number $N$ of intervals $I_1=[\lambda_a, \lambda_i], \dots, I_N=[\lambda_{N-1}, \lambda_b]$ with $\lambda_n = \lambda_a+n\epsilon_N$ and $\epsilon_N=(\lambda_b-\lambda_a)/N$, then on each interval $I_n$, $O'$ is approximately an inertial observer in the sense that $$   T_{\lambda_n} = P_n + \mathcal O(\epsilon_N), \qquad (\star) $$ for some Poincare transformation $P_n$.  Then we would note that since $O'$ is stationary in his own reference frame, he measures his worldline to have the property $\dot x'^\mu(\lambda) = (\dot t(\lambda), \mathbf 0)$ so that $$   I_{ba}=\int_{\lambda_a}^{\lambda_b}d\lambda \,\sqrt{-\eta_{\mu\nu}\dot x'^\mu\dot x'^\mu} = \int_{\lambda_a}^{\lambda_b} d\lambda \, \sqrt{\dot t^2} = t(\lambda_b) - t(\lambda_a) = t_{ba} $$ On the other hand the integral on the left can be written as a Riemann sum using the partition above, and we can invoke ($\star$) above to get \begin{align}   I_{ba}  &amp;= \lim_{N\to\infty}\left[\sum_{n=1}^N \epsilon_N\sqrt{-\eta_{\mu\nu}\dot x'^\mu(\lambda_n)\dot x'^\nu(\lambda_n)}\right] \notag\\ &amp;= \lim_{N\to\infty}\left[\sum_{n=1}^N \epsilon_N\sqrt{-\eta_{\mu\nu}\dot x^\mu(\lambda_n)\dot x^\nu(\lambda_n)} + \mathcal{O}(\epsilon_N^2)\right] \notag\\ &amp;= \int_{\lambda_a}^{\lambda_b}d\lambda \,\sqrt{-\eta_{\mu\nu}\dot x^\mu\dot x^\mu} \end{align} Combining these two computations gives the desired result.  How do others feel about this argument?  I'm not completely comfortable with it because of the assumption $(\star)$ I made on $T_\lambda$.  I imagine that in GR a similar argument could be made by invoking local flatness of the metric. Using Elseif Conditional Statement in QGIS Field Calculator? How to prove this limit exists: $a_{n+2}=\sqrt{a_{n+1}}+\sqrt{a_{n}}$ Question: Consider a sequence $\{a_{n}\}$ such that $a_{1},a_{2}&gt;0$, and for all $n \in \mathbb{N}$ we have:  $$a_{n+2}=\sqrt{a_{n+1}}+\sqrt{a_{n}}$$  Prove that :  $\displaystyle\lim_{n\to\infty}a_{n}$ exists and find this limit.  My work: If this limit exists, let $\displaystyle\lim_{n\to\infty}a_{n}=x&gt;0$; then we have $$x=\sqrt{x}+\sqrt{x}\Longrightarrow x=4$$ But I can't see how to prove the limit of $\{a_{n}\}$ exists. Thank you for you help! How to measure time taken by a function to execute I need to get execution time in milliseconds.  I originally asked this question back in 2008. The accepted answer then was to use  However, we can all agree now  that using the standard  API is more appropriate. I am therefore changing the accepted answer to this one. What does the “@@…@@” meta line with at signs in svn diff or git diff mean? I saw this question  but it doesn't have a full solution. What is the full solution to the 99 bottles of beer on the wall for Vim adventures?  Context: for the sake of being a good SO member I will give more details but a full solution will answer my question. It seems from reading the other post that my register is incorrect for some reason. I can't get the &lt;NL&gt;. I think that's the issue since pasting won't work... I am trying to master the homemade Neapolitan pizza, from dough preparation to cooking it.  After following the recommendations at Seriouseats.com for the dough preparation, I came across some doubts regarding the oven use.  I understand that ideally I would make it in a 900F wood oven, but at home we don't have such equipment!  What is the best practice to make the Neapolitan Pizza in a regular gas oven that heats up to 530F? (i.e. temperature, time, tray positioning...) Are there changes in the way the dough has to be prepared? Scala Lists of lists of integers How can I get better results when doing camera motion tracking? Whenever I do camera tracking in Blender the reconstruction is always zooming out or not on the axis. I have a great quality camera, but the end results of the camera tracking always has the model sliding. If you have a solution please tell me. What are the mechanics by which Time Dilation and Length Contraction occur? What are the mechanics of time dilation and length contraction? Going beyond the mathematical equations involving light and the "speed limit of the universe", what is observed is merely a phenomenon and not a true explanation of why time dilates or length contracts.  It has been proven to work out, but do we know why?  Is it something that happens at a subatomic level? I need a non trivial  examples of group isomorphism that maps $G\to H$ such that   $G/H \cong G$. Origin of the dot and cross product? Most questions usually just relate to what these can be used for, that's fairly obvious to me since I've been programming 3D games/simulations for a while, but I've never really understood the inner workings of them... I could get the cross product equation as a determinant of a carefully-constructed matrix,   but what I want to ask is... How did the dot and cross product come to be? When were they "invented"? Some detailed proofs? Did someone say: "Hey, wouldn't it be nice if we could construct a way to calculate a vector that is perpendicular to two given operands?"  Basically, how/why do they work?  I would appreciate explanations, links to other explanations, other web resources... I've been searching the Internet lately for explanations, but most of them are on how to use it and nothing that really gives substance to it.