Hot answers tagged

5

It doesn't delete 4.txt because you are running the rsync command with *, i.e. on the individual source files. Hence, rsync doesn't even consider 4.txt (or the containing directory). Instead, run it on the directory that contains the sources, by changing the * to . Then, rsync can look at the directory as a whole as see what is missing. rsync ...


4

You don't need a regular expression, you need extended globbing patterns. I assume your shell is bash: shopt -s extglob cd parent-directory-of-2015 for original in */*/!(*-+([0-9])x+([0-9]).jpg); do echo "an original: $original" done That pattern will exclude files with matching "-digitsxdigits.jpg"


2

When the * is not quoted the shell expands the argument list before running the command. It passes the expand argument list to the program. When the * appears in a quoted string it is not expanded by the shell before being passed to the program. Try expanding the path, assigning it to another variable, and then quoting the second variable when passing it ...


2

If you are performing activity on every file in a folder and putting the output file in the same folder, is not a wise approach in my opinion. My > output redirections always end up in /tmp, unless I know there is not enough space for my output there. Then I look for a more suitable filesystem for it. But never place them in the same directory as I am ...


2

Your reasoning is correct. Among your proposed solutions, i prefer the first two specially the second one as it seems cleaner to write to a file located in another directory. Here is another option using GLOBIGNORE variable (Given your shell supports this): GLOBIGNORE=LIST ## "LIST" file will be ignored while globbing for i in *; do echo "$i"; cut -d ' ...


2

You can't do it from the inside of your script. * has to be escaped, otherwise it will try to fit filenames (in your case x., then anything, as * is a glob operator that matches any string in filename). You can do it in, basically, three ways - enclose your string with single or double quotes: ./script.sh "x.*" ./script.sh 'x.*' Or prefix problematic ...



Only top voted, non community-wiki answers of a minimum length are eligible