Percentage progress on Automator application(.app) on Mac OS I have used Automator Application to create application(.app which runs by double clicking). It runs commands which executes command one by one. Every command takes 2-3 minutes. What I want to achieve is show percentage progress after completion of every command.    In above image percentage is always zero. I want to explicitly set progress after completion of every command. I also know this is possible using AppleScript but I want to implement in bash script.
How to add a progress bar to a shell script? When scripting in bash or any other shell in *NIX, while running a command that will take more than a few seconds, a progress bar is needed.  For example, copying a big file, opening a big tar file.  What ways do you recommend to add progress bars to shell scripts?
Print file content without the first and last lines Simulate repeated rolls of a 7-sided die with a 6-sided die What is the most efficient way to simulate a 7-sided die with a 6-sided die? I've put some thought into it but I'm not sure I get somewhere specifically.  To create a 7-sided die we can use a rejection technique. 3-bits give uniform 1-8 and we need uniform 1-7 which means that we have to reject 1/8 i.e. 12.5% rejection probability.  To create $n * 7$-sided die rolls we need $\lceil log_2(  7^n ) \rceil$ bits. This means that our rejection probability is $p_r(n)=1-\frac{7^n}{2^{\lceil log_2(  7^n ) \rceil}}$.  It turns out that the rejection probability varies wildly but for $n=26$ we get $p_r(26) = 1 - \frac{7^{26}}{2^{\lceil log_2(7^{26}) \rceil}} = 1-\frac{7^{26}}{2^{73}} \approx 0.6\%$ rejection probability which is quite good. This means that we can generate with good odds 26 7-die rolls out of 73 bits.  Similarly, if we throw a fair die $n$ times we get number from $0...(6^n-1)$ which gives us $\lfloor log_2(6^{n}) \rfloor$ bits by rejecting everything which is above $2^{\lfloor log_2(6^{n}) \rfloor}$. Consequently the rejection probability is $p_r(n)=1-\frac{2^{\lfloor log_2(  6^{n} ) \rfloor}}{6^n}$.  Again this varies wildly but for $n = 53$, we get $p_r(53) = 1-\frac{2^{137}}{6^{53}} \approx 0.2\%$ which is excellent. As a result, we can roll the 6-face die 53 times and get ~137 bits.  This means that we get about $\frac{137}{53} * \frac{26}{73} = 0.9207$ 7-face die rolls out of 6-face die rolls which is close to the optimum $\frac{log 7}{log6} = 0.9208$.  Is there a way to get the optimum? Is there an way to find those $n$ numbers as above that minimize errors? Is there relevant theory I could have a look at?  P.S. Relevant python expressions:  min([ (i, round(1000*(1-(  7**i )  /  (2**ceil(log(7**i,2)))) )/10)  for i in xrange(1,100)], key=lambda x: x[1]) min([ (i, round(1000*(1- ((2**floor(log(6**i,2))) / (  6**i ))   )    )/10)  for i in xrange(1,100)], key=lambda x: x[1])   P.S.2 Thanks to @Erick Wong for helping me get the question right with his great comments.  Related question: Does the given matrix have a square root? Given the following matrix, I was asked to tell whether the matrix is the square of some matrix or not.  $$ \begin{pmatrix} 1 &amp; 0 &amp; 0\\ 0 &amp; -1 &amp; 0\\ 0 &amp; 0 &amp; -1 \end{pmatrix} $$  Since this matrix is diagonal, a square root is  $$ \begin{pmatrix} 1 &amp; 0 &amp; 0\\ 0 &amp; i &amp; 0\\ 0 &amp; 0 &amp; i \end{pmatrix} $$ Am I right? How do I close a tkinter window? How do I end a Tkinter program? Let's say I have this code:  from Tkinter import *  def quit():     # code to exit  root = Tk() Button(root, text="Quit", command=quit).pack() root.mainloop()   How should I define the quit function to exit my application? I love recursion. I think it simplifies things a lot. Another may disagree; I think it also makes the code a lot easier to read. However, I've noticed that recursion is not used as much in languages such C# as they are in LISP (which by the way is my favorite language because of the recursion).   Does anybody know if there is any good reasons not use recursion in the languages such as C#? Is it more expensive than iteration? Behave as if it was or it were You can place the script in the head or body as you like. The   script will behave as if it was located exactly where you put the   script tag in the document.   The sentences above are taken from  (at the very bottom). I think they made a grammatical mistake here: it should be behave as if it were rather than it was. I'm not 100% sure, so want to confirm it. $\mathbb Z^n/\langle (a,...,a) \rangle \cong \mathbb Z^{n-1} \oplus \mathbb Z/\langle a \rangle$ It has been discussed before, but in light of some of the , I can't help but wonder what is accomplished by displaying the author of a given question or answer.  There is a , but if anything, I don't think it goes far enough.  If questions and answers are supposed to stand on their own merit, why do we need to show the author at all?  I'm not proposing any change to the way rep works; rep should still be accrued and abilities gained.  The only difference is that questions and answers would appear anonymous.  Does this better reflect the goals of SO?  If so, how far do you think the anonymity should be taken?  If not, what shortcomings am I missing? I am trying to calculate the last two digits of $3^{400}$, but working $\bmod {100}$ is proving intractable. I did the last digit case pretty handily, and now I'm stuck at last two. Running "sudo apt-get update" returns connection errors After installing Ubuntu 18.04 from the Windows store I open Bash and want to run sudo apt-get update, but this returns the following errors:  Err:1 http://security.ubuntu.com/ubuntu bionic-security InRelease   Connection failed [IP: 91.189.91.26 80] Err:2 http://archive.ubuntu.com/ubuntu bionic InRelease   Connection failed [IP: 91.189.88.162 80] Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease   Connection failed [IP: 91.189.88.161 80] Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease   Connection failed [IP: 91.189.88.162 80] Reading package lists... Done W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Connection failed [IP: 91.189.88.162 80] W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Connection failed [IP: 91.189.88.161 80] W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Connection failed [IP: 91.189.88.162 80] W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Connection failed [IP: 91.189.91.26 80] W: Some index files failed to download. They have been ignored, or old ones used instead.   When I open 91.189.91.26 in a browser, it shows the site without a problem.  Previously this worked without any problem, but I did a clean reinstall of Windows and now it doesn't work anymore. It seems some firewall or proxy issue, but I tried with the firewall disabled and I got the same result.  Any idea why this is happening? Maybe it is a 18.04 issue? If so, is it possible to return to 16.04 on Windows 10? Becasue I don't see a uninstall option. How can I reset or revert a file to a specific revision? I have made some changes to a file which has been committed a few times as part of a group of files, but now want to reset/revert the changes on it back to a previous version.   I have done a git log along with a git diff to find the revision I need, but just have no idea how to get the file back to its former state in the past. Quick-and-dirty way to ensure only one instance of a shell script is running at a time What's a quick-and-dirty way to make sure that only one instance of a shell script is running at a given time? Integral of type $\displaystyle \int\frac{1}{\sqrt[4]{x^4+1}}dx$ Resolve build errors due to circular dependency amongst classes Referring to correctly-styled algpseudocode procedure name in document Given an algorithm written in algpseudocode:  \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm}   \caption{Part 1}   \begin{algorithmic}[1]     \Procedure {FooProc}{$G$}       \State ...     \EndProcedure   \end{algorithmic} \end{algorithm} \end{document}   How can I now refer to FooProc in my document (outside of the algorithm environment) such that it has the same typeset as in inside the algorithm environment? Effect Of Frequency on Photocurrent The situation is this.. I am performing a photoelectric effect experiment - just the usual - evacuated glass tube containing two metal electrodes connected to an external source of DC voltage (say an alkaline cell) and ammeter in series. I shine a light on one of the electrodes - the frequency is more than enough to cause eject photoelectrons, and the voltage of the cell opposes the electrons which are trying to get to the other electrode. The question is this - what happens to the current on increasing the intensity of light while keeping no. of photons falling on the electrode constant (in other words increasing the frequency)?   Does the current remain the same because the no. of photons falling on the electrode is constant and so no. of electrons being ejected is constant? Or does it increase because the electrons have more kinetic energy, ie, they are moving faster towards the other electrode so that the $t$ (time) term in $I$ = $q$/$t$ is less ($q$ remains constant because no. of electrons being ejected is still the same)?   This question appeared in one of my tests and the answer key says that the current remains constant but think that case 2 is correct and current would increase, which is why I asked this question.  Thanks. Viewing computer screen through 3D glasses, why the asymmetry? I have 3D glasses made up of plastic.  First case: When I hold front side of the 3D glasses (by this I mean that side on which light falls) in front of a computer screen, light coming from screen is not blocked, at any angle of rotation. But I see somewhat (slightly) bluish screen when 3D glasses are held horizontally; and yellowish (slightly) screen when glasses are held vertically.  Second case: Now I flip the side of the glasses i.e. "back" side of glasses is in front of screen and "front" side is closer to eyes. In this second case, when glasses are held horizontally, the light is blocked. When glasses are held vertically, light is not blocked; I can see the screen. For intermediate angle, intensity of light varies from minimum to maximum.  Questions:   Why I get slightly colored screens in the first case and why light is not blocked ? Why light is blocked in the second case ?   I know (after reading somewhere) that glasses consists of a pair of circular polarizer and linear polarizer. Circular polarizer in my first case will be near to computer screen and linear polarizer will be near to eyes; and in second case vice versa. Does there exist a continuous function such that f(x) is rational for every irrational x, and f(x) is irrational for every rational x? Does there exist a continuous function such that f(x) is rational for every irrational x, and f(x) is irrational for every rational x? I can think of examples where this would be true, but I'm having a lot of trouble with the continuity. This is NOT an installation problem question. I've had both op sys working fine side-by-side for a couple of weeks now. I'm using Ubunutu 12.04 64-bit.  This morning when I tried to switch from Win8 to Ubuntu, it just rebooted into Win8. No grub screen whatsoever. This is the 3rd machine I've had dual-booting &amp; have never seen this, but then Win8 is a 1st for me &amp; has thrown some pretty awesome blocks in the path to get to here. Atrocious op sys...  I'm assuming the ASUS updater did this yesterday. (ASUS R503U)  So, do I just put the Ubuntu disk in &amp; reinstall grub? Smooth structure of embedded submanifolds Here is a rather long quotation from "Introduction to smooth manifolds" by J. Lee.     Proposition 5.2 (Images of Embeddings as Submanifolds). Suppose $M$ is a   smooth manifold with or without boundary, $N$ is a smooth manifold, and   $F: N \to M$ is a smooth embedding. Let $S = F(N)$. With the subspace   topology, $S$ is a topological manifold, and it has a unique smooth   structure making it into an embedded submanifold of $M$ with the   property that $F$ is a diffeomorphism onto its image.      Proof. If we give $S$ the subspace topology that it inherits from $M$,   then the assumption that $F$ is an embedding means that $F$ can be   considered as a homeomorphism from $N$ onto $S$, and thus $S$ is a   topological manifold. We give S a smooth structure by taking the   smooth charts to be those of the form $(F(U), \phi \circ F^{-1})$, where $(U, \phi)$   is any smooth chart for $N$; smooth compatibility of these charts   follows immediately from the smooth compatibility of the   corresponding charts for $N$. With this smooth structure on $S$, the map   $F$ is a diffeomorphism onto its image (essentially by definition), and   this is obviously the only smooth structure with this property. ...   My question is about the bold sentence. He says that it is obvious, but it is not obvious to me. Why is the constructed smooth structure the only smooth structure that makes $F$ a diffeomorphism between $N$ and $S$?