19

The POSIX specification is the definitive reference on how unix tools should behave. The section on pathname resolution explains the meaning of trailing slashes in file names. A pathname that contains at least one non-<slash> character and that ends with one or more trailing <slash> characters shall not be resolved successfully unless the last ...


6

In the bash shell, you should enable extglob and run ls !(*.js). Example: $ touch file.js file.txt $ shopt -s extglob $ ls !(*.js) file.txt


3

I would use find for this: find . \( -name .git -o -name node_modules -o -name wp-snapshots \) -prune -o -type f -print | wc -l This looks for all files (including directories) starting from the current directory, and processes them as follows: if the name matches .git, node_modules, or wp-snapshots, the tree starting from the matching entry is ignored ...


3

Personally, in a situation where I'm about to give the command interactively, I would just do mv *tut* tutorials and expect to get the "cannot move" error. It's is harmless and the other files and directories will have been moved as expected. The exit status of the command will be non-zero, signalling an error, but since nothing depends on it, it may be ...


2

There are several hints that a */ should match only directories is bash manual (emphasis mine): * Matches any string, including the null string. When the globstar shell option is enabled, and * is used in a pathname expansion context, two adjacent *s used as a single pattern will match all files and zero or more directories and subdirectories. If ...


2

Even simpler: awk '$3' inputfile This is shorthand for awk '$3!=""', which is shorthand for awk '$3!=""{print}', which is short for awk '$3!=""{print $0}' For the record: sed /-$/d is probably faster, and grep -ve '-$' even faster still.


2

To print lines that end in an alphanumeric character is simply: $ awk '/[[:alnum:]]$/' file MN_L_DAX-NORDNET_D36 - DK0060975886 MN_L_DAX-NORDNET_D35 - DK0060975613


1

Thanks to @guillermo chamorro suggestion I was able to achieve the desired output by modifying my script in the following way: awk '!/^.* -$/' sourcefile.txt > temp.txt && mv temp.txt sourcefile.txt Thank you Guillermo.


1

You can find some explanation in the bash manual, Pattern matching 3.5.8.1 Pattern Matching Any character that appears in a pattern, other than the special pattern characters described below, matches itself. The NUL character may not occur in a pattern. A backslash escapes the following character; the escaping backslash is discarded when ...


1

find -name can work with ??11* or ??52*. It's not regex but it may be enough. find . -name '??11*' -o -name '??52*' Note ? can match a non-digit. To match a digit use [0123456789]. The forms [[:digit:]] or [0-9] are useful in general but locale-dependent. I can see the filenames in question use 0123456789 for sure, so [0123456789] is the best choice. ...


1

I get the following message: mv: cannot move 'tutorials' to a subdirectory of itself, 'tutorials/tutorials' Just ignore the error. No, really. You know you're going to get the error since the glob pattern matches the target. You also know it doesn't mean anything, since the system can't move the directory inside itself, and it's smart to enough to realize ...


1

You can also use find: find . -type d -name "*tut*" -not -path "./tutorials" -exec mv -t "tutorials" {} +


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