How can I use inverse or negative wildcards when pattern matching in a unix/linux shell?

In Bash you can do it by enabling the extglob option, like this (replace ls with cp and add the target directory, of course) ~/foobar> shopt extglob extglob off ~/foobar> ls abar afoo bbar bfoo ~/foobar> ls !(b*) -bash: !: event not found ~/foobar> shopt -s extglob # Enables extglob ~/foobar> ls !(b*) abar afoo … Read more

How to loop over files in directory and change path and add suffix to filename

A couple of notes first: when you use Data/data1.txt as an argument, should it really be /Data/data1.txt (with a leading slash)? Also, should the outer loop scan only for .txt files, or all files in /Data? Here’s an answer, assuming /Data/data1.txt and .txt files only: #!/bin/bash for filename in /Data/*.txt; do for ((i=0; i<=3; i++)); … Read more

How to use glob() to find files recursively?

pathlib.Path.rglob Use pathlib.Path.rglob from the the pathlib module, which was introduced in Python 3.5. from pathlib import Path for path in Path(‘src’).rglob(‘*.c’): print(path.name) If you don’t want to use pathlib, use can use glob.glob(‘**/*.c’), but don’t forget to pass in the recursive keyword parameter and it will use inordinate amount of time on large directories. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)