I want to archive my photos into tar archives.  The directory containing photos has one dir per year and multiple dirs inside each year dir:  Photos     2005     2006         Some dir with spaces             Pic1.jpg             Pic2.jpg             ...         Other dir here         ...     2007     ...   Target structure should also contain a directory per year, but inside a year dir I would have tar.gz files for each subdir from source dir, like this:  Backup     2005     2006         Some_dir_with_spaces.tar.gz         Other_dir_here.tar.gz         ...     2007     ...   Script which I'm creating to do this looks as follows:  cd ~/Photos for y in * do     YEAR_DIR=~/Backup/$y     mkdir -p $YEAR_DIR      pushd $y      for d in *     do         f=`echo $d | tr ' ' '_' | tr -d ',.!'`  # Clean the name         t=$YEAR_DIR/$f.tar.gz         d=$(printf '%q' "$d")         # echo tar czf $t "$d"  # This outputs the command as expected         tar czf $t "$d"  # but executing it results in error: Cannot stat: No such file or directory     done      popd done   As hinted in the comment, echoing the prepared command looks fine, and also if I copy that statement and execute it from terminal it works, but executing it within the script (tar czf $t "$d") results in an error:   tar: Some\ dir\ with\ spaces: Cannot stat: No such file or directory   What am I doing wrong?  P.S. I'm doing this on a Mac.
Or, an introductory guide to robust filename handling and other string passing in shell scripts.  I wrote a shell script which works well most of the time. But it chokes on some inputs (e.g. on some file names).  I encountered a problem such as the following:   I have a file name containing a space hello world, and it was treated as two separate files hello and world. I have an input line with two consecutive spaces and they shrank to one in the input. Leading and trailing whitespace disappears from input lines. Sometimes, when the input contains one of the characters \[*?, they are replaced by some text which is is actually the name of files. There is an apostrophe ' (or a double quote ") in the input and things got weird after that point. There is a backslash in the input (or: I am using Cygwin and some of my file names have Windows-style \ separators).   What is going on and how do I fix it?
At what time will the upcoming Ubuntu release be made available? I'm trying to determine if there is a best practice for typesetting the "evaluated at" bar for derivatives. The three possibilities I'm thinking of are shown in the code excerpt below:  \begin{gather*} 5 + \frac{df}{dt} \Bigr\rvert_{t = 0} \\ 5 + \frac{df}{dt} \biggr\rvert_{t = 0} \\ 5 + \left. \frac{df}{dt} \right\rvert_{t = 0} \\ \end{gather*}     The \Bigr option doesn't quite reach the top and bottom of the fraction. The \biggr option overshoots the top and bottom of the fraction by a little bit. And the \left...\right option has the same height as the \biggr option, but it introduces a little extra space between the + and the fraction. I'm having trouble deciding between these options. Is there a best practice for typesetting this? Auto generate an Index Is there any way to auto-gererate an index for the makeidx package? I've written ~270 pages and didn't think of adding \index{} everywhere.  Do I really need to go over everything and add \index{}? How to distribute proprietary Mathematica code Shell script zips a folder, but exclude parameters not working IF its run from cron.daily !! Do not use the future tense after unless   [✓]  I won't go unless you go   [✘] [I won't go] unless you will go. [✘]   Why not? Even if the above is prescriptive, what may be some reasons? In my separate question , I quote: unless = if not. If not can precede future tense; so why can't unless?  Footnote:  motivated this. What is the exact difference between an autoregressive (AR) and vector autoregressive model (VAR)?  I always thought that VAR would just be for more than two variables, until I learned that AR can also have more than two variables. I.e. I had a misunderstanding(?) that AR models are not always bivariate.  Before I write too much potentially false assumptions about the difference between AR and VAR, it would rather be interested to see if anyone can make provide a quick and good summary. Privilege banner buggy? Or am I just confused? On the main Stack Overflow site, I arrived and had a banner: "Congrats, you've gained the privilege – create wiki posts and 3 other privileges" This confuses me, because I only see two privileges listed at 100%. Is the banner just buggy?  Or is there a better place to see my privileges that the page linked to by that banner? Does the alarm work when my phone is turned off? This is a bit of a more unusual bug to report:    The screenshot above is unedited - the black box is rendered by the Stack Exchange application.  Phone:  running Android 4.0.4 (ICS) Show that $\mathbb{E}(T) = \sum\limits^\infty_{k=1}\mathbb{P}(T \geq k)$ for $T$ nonnegative integer valued and $E[T] < \infty$ Let T be a non-negative integer-valued random variable with $\mathbb{E}(T) &lt; \infty $. Prove that $\mathbb{E}(T) = \sum^\infty_{k=1}\mathbb{P}(T \geq k)$.  Had a few attempts, haven't really got anywhere. I'm wondering as I'm typing this if proof by induction is a good way to go.  Edit: One major thing I forgot to add, am I correct in thinking that also, $\mathbb{E}(T) = \sum^\infty_{k=1}k\mathbb{P}(T = k)$? MikTex 2.9 Installation Error: File name database capacity exceeded. How do I translate an ISO 8601 datetime string into a Python datetime object? Does there exist a polynomial $p(x) \in \mathbb C[x]$ such that $p(x) \notin \mathbb R[x]$ and $p(x)p(-x)=p(x^2)$ ?  I have noticed that if $a_n$ is the leading coefficient of $p(x)$ then $a_n=(-1)^n $, so the leading coefficient cannot be imaginary; also $p(0)^2=p(0)$ so the constant term also is real. Please help. Thanks in advance. For example:     There's two options here   or     There are two options here   I hear a lot of people say the first line (or something similar), but isn't that incorrect? Isn't it plural and therefore you should use "there are"? Regex match entire words only How do I remap certain keys or devices? Ubuntu non LTS to LTS in the future What do you wish someone had told you before your first commute? Why don't I hear any sound after calling the Beep function in Windows 7?