Tag Info

Hot answers tagged

24

That's a really nice catch. From a quick look at the source code for GNU find, I would say this boils down to how fnmatch behaves on invalid byte sequences (pred_name_common in pred.c): b = fnmatch (str, base, flags) == 0; (...) return b; This code tests the return value of fnmatch for equality with 0, but does not check for errors; this results in any ...


14

heemayl is correct about the location of crontab files on Linux, but it might be different on other operating systems and "theoretically" is could also be in a different location on Linux. Essentially, when a special interface is provided to access the files, you should use it. This will ensure that cron gets to check the files before installing them, makes ...


13

find -name option uses shell pattern matching notation to perform matching filename. * is a pattern matching multiple characters, shall match a string of zero or more characters. find uses fnmatch to check pattern matching, so you can use ltrace to check the result: $ touch $'\U1212'aa $ touch D$'\351'sinstaller $ LC_ALL=en_US.utf8 ltrace -e fnmatch find ...


11

A case-insensitive filesystem just means that whenever the filesystem has to ask "does A refer to the same file/directory as B?" it compares the names of files/directories ignoring differences in upper/lowercase (exactly what upper/lowercase differences count depends on the filesystem—it's non-obvious once you get beyond ASCII). A case-sensitive filesystem ...


5

The location of cron files for individual users is /var/spool/cron/crontabs/. From man crontab : Each user can have their own crontab, and though these are files in /var/spool/cron/crontabs, they are not intended to be edited directly.


4

dir=${1%/} will take the script's first parameter and remove a trailing slash if there is one.


2

For various reasons related to whitespace issues, etc., it is not advisable to parse the output of ls. An alternative, which uses GNU versions of find, sort, sed: find . -mindepth 1 -maxdepth 1 -printf "%A@ %f\0" | sort -rnz | sed -z 's/^[0-9.]\+ //' find is, of course, much more flexible than ls when it comes to listing and filtering files, but it ...


1

Extension doesn't really matter, but I'd name it .sh since this is shell commands, not a set of option: value. But be careful that if you don't include those lines in your .bashrc, you will need to source it anytime you need these variables in a new terminal. $ echo $PYTHONPATH $ source /pat/to/my_conf.sh $ echo $PYTHONPATH /home/myuser/squish-5.0-xyz/lib ...


1

To remove a trailing slash if there is one, you can use the suffix removal parameter expansion construct present in all POSIX-style shells: x=${x%/} There are a few complications. This only removes a single slash, so if you started with a/b/c// then you'll still end up with a slash. Furthermore, if the original path was /, you need to keep the slash. ...


1

Background reading: Why does my shell script choke on whitespace or other special characters?, Why you shouldn't parse the output of ls Setting IFS to a newline means that only newlines, and not spaces and tabs, will be treated as separators during the expansion of the command substitution. Your method will not support file names that contain newlines; this ...


1

Do you really mean adding * in filename? Or you mean the output of ls gives filename ending in * if it has execute permission? If only output problem of ls, you could simply solve by: replace ls to \ls, this is to use un-aliased version of ls, which doesn't output *



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