glob

PHP - How do I open files and read them then write new ones with “x” lines per file?

…衆ロ難τιáo~ 提交于 2020-01-13 19:12:39
问题 I posted this question here before but there were no responses. I may have done something wrong so, here it is again with some more details. The files in the directory are named 1.txt, 2.txt, 3.txt etc.... The snippet below enters that directory, opens all the *,txt files reading them, removes the dupes and creates one file with all the unique contents. (names in this case). $files = glob($dirname."/*.txt"); //matches all text files $lines = array(); foreach($files as $file) { $lines = array

PHP - How do I open files and read them then write new ones with “x” lines per file?

风流意气都作罢 提交于 2020-01-13 19:12:28
问题 I posted this question here before but there were no responses. I may have done something wrong so, here it is again with some more details. The files in the directory are named 1.txt, 2.txt, 3.txt etc.... The snippet below enters that directory, opens all the *,txt files reading them, removes the dupes and creates one file with all the unique contents. (names in this case). $files = glob($dirname."/*.txt"); //matches all text files $lines = array(); foreach($files as $file) { $lines = array

Including/excluding globs for gulp.src

时间秒杀一切 提交于 2020-01-13 19:01: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,

How do I avoid URL globbing with PHP cURL?

╄→尐↘猪︶ㄣ 提交于 2020-01-13 18:22:28
问题 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

Why does glob lstat matching entries?

狂风中的少年 提交于 2020-01-12 18:54:50
问题 Looking into behavior in this question, I was surprised to see that perl lstat()s every path matching a glob pattern: $ mkdir dir $ touch dir/{foo,bar,baz}.txt $ strace -e trace=lstat perl -E 'say $^V; <dir/b*>' v5.10.1 lstat("dir/baz.txt", {st_mode=S_IFREG|0664, st_size=0, ...}) = 0 lstat("dir/bar.txt", {st_mode=S_IFREG|0664, st_size=0, ...}) = 0 I see the same behavior on my Linux system with glob(pattern) and <pattern> , and with later versions of perl. My expectation was that the globbing

Bash globbing - autoexpand for a few specific cases?

本秂侑毒 提交于 2020-01-10 10:22:13
问题 I understand that the wildcard * (by itself) will expand in such a way that it means "all non-hidden files in the current folder" with hidden files being those prefixed by a period. There are two use cases that I would think are useful, but I don't know how to properly do: How can you glob for... "All files in the current folder, including hidden files, but not including . or .. "? How can you glob for... "All hidden files (and only hidden files) in the current folder, but not including . or

Problems with command using * wildcard in subprocess

牧云@^-^@ 提交于 2020-01-09 11:44:28
问题 I'm trying to copy files from one location to another using subprocess library and Popen method. When runing following script I'm getting the error cp: cannot stat /some/dev_path/* . I was told that the * is not expanded to the file names and that's where the problem is. Also in some other posts people were suggesting to use call instead of Popen, but call will not return stderr as far as I know. devPath = '/some/dev_path/' productionPath = '/some/prod_path/' p = subprocess.Popen(['cp', '-r',

csh set: no match error wildcard

為{幸葍}努か 提交于 2020-01-07 03:22:44
问题 trying to look up files in directories with wildcard *, and put the names into an array the files have similar names (MATCHr1, MATCHr2 ... ) the problem arises when the file does not exist (which is a possibility) set command returns a "no match" error and terminates the loop if this happens how can i get it handle the error by jumping to the next iteration? set SUBIDS = (10003 10005 10006) foreach SUBID ($SUBIDS) foreach SEQR ( MATCH ENC NBACK SIMON FACE ) ls -l *${SEQR}*.nii.gz set Array =

parse_args all .png files from a parser argument

喜欢而已 提交于 2020-01-06 06:28:30
问题 I would like to get a arg.pics which returns something like ['pic1.png', 'pic2.png', 'pic3.png'] (to arbitrarily parse all files of .png format) after running the following ( test.py ): import argparse import os def parser_arg(): par = argparse.ArgumentParser() parser = par.add_argument_group('pictures') parser.add_argument("-p", "--pics", nargs="+", help="picture files", required=True) arguments = par.parse_args() return arguments args = parser_arg() And upon running the script via command

How to search file in folder by using php?

落花浮王杯 提交于 2020-01-05 07:32:03
问题 I have a folder called allfiles , and there are some files in this folder, such as 1212-how-to-sddk-thosd.html 3454-go-to-dlkkl-sdf.html 0987-sfda-asf-fdf-12331.html 4789-how-to-fdaaf-65536.html I use scandir to list all files, and now I need to find the file by with keywords, example to-dlkkl is the keyword, and I will get the file 3454-go-to-dlkkl-sdf.html . Glob seems not work, and opendir and readdir are not work well, any ideas? 回答1: Use loop foreach and strpos function: $files = scandir