New answers tagged

0

Either you ran set -f earlier in the script, which disables wildcard expansion, or there are no matching files. If there are no matching files, the pattern is left unchanged, so the for loop runs on one element which is the unchanged pattern. In bash, you can use shopt -s nullglob to make non-matching patterns instead expand to the empty list.


0

i am not sure that i understand your code, for f in ~/1/2/*/*_1.txt; do fdn="${f%/*}" fbn1="${f##*/}" fbn2="${fbn1//_1/_2}" fbn3="${fbn1//_1/_3}" fbn4="${fbn1//_1/_4}" expTool INPUT1= "$fdn/$fbn1" INPUT2= "$fdn/$fbn2" OUTPUT1= "$fdn/$fbn3" OUTPUT2= "$fdn/$fbn4" done if i am of toppic please let me know , i delete my answer!


0

The problem isn't tar, it's in your shell code. The argument of the -C option is supposed to be a path, not a wildcard pattern. Notice that you had exactly the same problem with the cd command. You stored a wildcard pattern in the INSTALL_DIR variable. When you write -C $INSTALL_DIR, this applies the “split+glob” operator: take the value of the variable, ...


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 ' ...


0

Looks like the x within the size of the image in the name could be used, so I'd write it something like this. looking for any file thats name does not have the x using a substring then copy all of them, leaving the others alone. #!/bin/bash typeset -i count let count=0 MAXF="$(find /path -type f -name "*.*" | wc -l)" find /path -type f -name "*.*" | ...


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"


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 ...


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 ...


0

If you want to exclude, try tree -I "*.[1-9][1-9][1-9][5-9]". Anything that can't match will either have a forbidden 0 in at least one of the first 3 slots or will be >4 in the last.



Top 50 recent answers are included