glob

PHP glob() doesnt find .htaccess

江枫思渺然 提交于 2019-12-06 03:02:55
问题 Simple question - How to list .htaccess files using glob() ? 回答1: glob() does list "hidden" files (files starting with . including the directories . and .. ), but only if you explicitly ask it for: glob(".*"); Filtering the returned glob() array for .htaccess entries with preg_grep: $files = glob(".*") AND $files = preg_grep('/\.htaccess$/', $files); The alternative to glob of course would be just using scandir() and a filter (fnmatch or regex): preg_grep('/^\.\w+/', scandir(".")) 回答2: in

How do I avoid URL globbing with PHP cURL?

[亡魂溺海] 提交于 2019-12-06 02:28:08
I have a url (slightly modified) like so: https://ssl.site.com/certificate/123/moo.shoo?type=456&domain=$GH$%2fdodo%20[10%3a47%3a11%3a3316] It doesn't work the way I intend it to when passed straight through to PHP cURL because of the brackets. I managed to run the same URL successfully in the command line like so: curl -g "https://ssl.site.com/certificate/123/moo.shoo?type=456&domain=$GH$%2fdodo%20[10%3a47%3a11%3a3316]" Is there an option (similar to -g, for disabling globbing) that I can use in PHP cURL? If not, how should I encode or format my URL before passing it to PHP cURL? Currently I

Including/excluding globs for gulp.src

六眼飞鱼酱① 提交于 2019-12-06 01:16:08
I'm trying to setup a glob array for my javascript concat build task in gulp . The directory structure looks as follows: ├── about │ └── about.js ├── assets ├── contact ├── core │ ├── navbar │ │ ├── navbar.js │ │ └── navbar.test.js │ ├── routing.js │ ├── routing.test.js │ ├── utils.js │ └── utils.test.js ├── generated │ ├── footer.js │ ├── header.js │ └── templates.js ├── home ├── app.js └── config.js The order of the files is important: generated/header.js app.js any of the *.js files, except those here below generated/templates.js generated/footer.js I've wildly tried all kinds of wildcards

Globbing accented files in Bash

风流意气都作罢 提交于 2019-12-05 20:34:17
I'm trying to verify a file exists in Bash . I know the file name (in a variable) but not the extension (can be .pmdl or .umdl ). on OSX, this works: $> ls ecole.pmdl $> filename="ecole" $> ls "$filename."[pu]mdl ecole.pmdl But it doesn't when the file name contains an accent: $> ls école.pmdl $> filename="école" $> ls "$filename."[pu]mdl ls: école.[pu]mdl: No such file or directory However it works if I don't use globbing: $> ls "$filename."pmdl école.pmdl I'm looking for a simple solution that works in both Linux & OSX. This is the closest question I found on that topic. Edit: $> bash -

How do I find the first 5 files in a directory with PHP?

Deadly 提交于 2019-12-05 19:47:03
How would I list the first 5 files or directories in directory sorted alphabetically with PHP? Using scandir() : array_slice(array_filter(scandir('/path/to/dir/'), 'is_file'), 0, 5); The array_filter() together with the is_file() function callback makes sure we just process files without having to write a loop, we don't even have to care about . and .. as they are directories. Or using glob() - it won't match filenames like .htaccess : array_slice(glob('/path/to/dir/*.*'), 0, 5); Or using glob() + array_filter() - this one will match filenames like .htaccess : array_slice(array_filter(glob('

Gulp glob to ignore file types and not copy empty folders

做~自己de王妃 提交于 2019-12-05 08:33:52
I have created a glob for gulp which ignores javascript and coffeescript files within a set of directories. I'd like it to copy all other files into a directory which works fine. The only problem is that when there are only javascript or coffeescript files it copies an empty folder. Any ideas how this glob could be amended to not copy empty folders? gulp.task('copyfiles', function(){ gulp.src('apps/*/static_src/**/!(*.js|*.coffee)') .pipe(gulp.dest('dest')); }); Example source files: apps/appname/static_src/images/image.jpg apps/appname/static_src/js/script.js Expected output: dest/static_src

Can NOT List directory including space using Perl in Windows Platform

喜夏-厌秋 提交于 2019-12-05 04:04:48
In order to list pathes in Windows,I wrote below Perl function(executed under StrawBerry runtime environment). sub listpath { my $path = shift; my @list = glob "$path/*"; #my @list = <$path/*>; my @pathes = grep { -d and $_ ne "." and $_ ne ".." } @list; } But it can't parse directory including space correctly, for example: When I issued following code: listpath("e:/test/test1/test11/test111/test1111/test11111 - Copy"); The function returned an array including two elements: 1: e:/test/test1/test11/test111/test1111/test11111 2: - I am wondering if glob could parse above space directories.

Gulp copying empty directories

大憨熊 提交于 2019-12-05 03:27:03
In my gulp build I've made a task that runs after all compiling, uglifying and minification has occurred. This task simply copies everything from the src into the dest directory that hasn't been touched/processed by earlier tasks. The little issue I'm having is that this results in empty directories in the dest directory. Is there a way to tell the gulp.src glob to only include files in the pattern matching (like providing the 'is_file' flag)? Thanks. null Fixed it by adding a filter to the pipeline: var es = require('event-stream'); var onlyDirs = function(es) { return es.map(function(file,

Using argparse in conjunction with sys.argv in Python

不问归期 提交于 2019-12-04 23:54:21
问题 I currently have a script, which uses file globbing via the sys.argv variable like this: if len(sys.argv) > 1: for filename in sys.argv[1:]: This works great for processing a bunch of files; however, I would like to use this with the argparse module as well. So, I would like my program to be able to handle something like the following: foo@bar:~$ myScript.py --filter=xyz *.avi Has anyone tried to do this, or have some pointers on how to proceed? 回答1: If I got you correctly, your question is

PHP glob() in bracketed directories

为君一笑 提交于 2019-12-04 23:17:43
问题 On a Windows machine, the following script: <?php mkdir("c:\\[test]"); file_put_contents("c:\\[test]\\test.txt", "some content"); chdir("c:\\[test]"); echo getcwd()."\n"; var_dump(glob('*')); ?> Displays this: C:\[test] array(0) { } When this is expected: C:\[test] array(1) { [0]=> string(8) "test.txt" } I understand that glob treats brackets as special characters, when found in the pattern parameter. The pattern * matches any file in the current working directory. However, glob() behaves as