glob

grep filename[asterisk] returns unexpected result

流过昼夜 提交于 2019-12-06 15:24:21
I have a basic question about ls command. Suppose in a directory I have 4 files named run run1 running run.sh So, if i do: ls -l|grep run* then I get no result. But if i do ls -l|grep run.* then I get run.sh as a result. However I expected grep to list all of the files in both the cases. Could you make me understand what is going on behind scenes? As long as I understand, the "*" is expanded by the shell before executing the command itself, so your grep will try to catch a string with all the file names! On the other hand, grep expects a regular expression, so the "*" is not interpreted as you

php glob number range in filename

谁说胖子不能爱 提交于 2019-12-06 15:04:00
I've checked two other answers but can't seem to match a range of numbers in file name I need to match 1.jpg to anything upto 99.jpg (no leading zeros and no prefix or suffix), just plain digits.jpg glob("$dir/{1..99}.jpg", GLOB_BRACE); and I've also tried: glob("$dir/{" . implode(",", range(1, 99)) . "}.jpg", GLOB_BRACE); The following matches only 1.jpg to 9.jpg but not 10,11 etc glob("$dir/[0-9].jpg", GLOB_BRACE); The following matches nothing: glob("$dir/[0-9]+.jpg", GLOB_BRACE); I've already checked solutions in PHP glob range small issue why? and php glob pattern match for arbitray

BASH: Copy all files and directories into another directory in the same parent directory

断了今生、忘了曾经 提交于 2019-12-06 13:26:30
问题 I'm trying to make a simple script that copies all of my $HOME into another folder in $HOME called Backup/ . This includes all hidden files and folders, and excludes Backup/ itself. What I have right now for the copying part is the following: shopt -s dotglob for file in $HOME/* do cp -r $file $HOME/Backup/ done Bash tells me that it cannot copy Backup/ into itself. However, when I check the contents of $HOME/Backup/ I see that $HOME/Backup/Backup/ exists. The copy of Backup/ in itself is

Where is gitignore recursive behavior specified?

僤鯓⒐⒋嵵緔 提交于 2019-12-06 08:57:16
Referring to the online docs : If the pattern does not contain a slash /, Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the .gitignore file (relative to the toplevel of the work tree if not from a .gitignore file). To me, this documentation says that given a pattern 'foo', any file or directory named 'foo' will be ignored only relative to the .gitignore file. I don't read anything explaining its recursive behavior. Shell globs (from what I read and experience) are not recursive. Now further below it explains the double asterisk: A

TextIO. Read multiple files from GCS using pattern {}

天大地大妈咪最大 提交于 2019-12-06 07:28:02
问题 I tried using the following TextIO.Read.from("gs://xyz.abc/xxx_{2017-06-06,2017-06-06}.csv") That pattern didn't work, as I get java.lang.IllegalStateException: Unable to find any files matching StaticValueProvider{value=gs://xyz.abc/xxx_{2017-06-06,2017-06-06}.csv} Even though those 2 files do exist. And I tried with a local file using a similar expression TextIO.Read.from("somefolder/xxx_{2017-06-06,2017-06-06}.csv") And that did work just fine. I would've thought there would be support for

Java Globbing Pattern to Match Directory and File

冷暖自知 提交于 2019-12-06 06:08:01
I'm using a recursive function to traverse files under a root directory. I only want to extract *.txt files, but I don't want to exclude directories. Right now my code looks like this: val stream = Files.newDirectoryStream(head, "*.txt") But by doing this, it will not match any directories, and the iterator() gets returned is False . I'm using a Mac, so the noise file that I don't want to include is .DS_STORE . How can I let newDirectoryStream get directories and files that are *.txt ? Is there a way? You really should use FileVisistor , it makes the code as simple as this: import java.nio

Chain Gulp glob to browserify transform

只谈情不闲聊 提交于 2019-12-06 05:51:34
问题 I have a project with a few relatively disjoint pages, each including their own entry point script. These scripts require a number of others using commonjs syntax, and need to be transformed by 6to5 and bundled by browserify. I would like to set up a gulp task that captures all the files matching a pattern and passes them on to the bundler, but I'm not sure how to pass files from gulp.src to browserify(filename) . My gulpfile looks like: var gulp = require("gulp"); var browserify = require(

Regular expression, glob, Python

六眼飞鱼酱① 提交于 2019-12-06 04:46:50
I have a folder, contains many files. There is a group contains pc_0.txt,pc_1.txt,...,pc_699.txt. I want to select all files beetween pc_200 - > to pc_699.txt How? for filename in glob.glob("pc*.txt"): global_list.append(filename) For this specific case, glob already supports what you need (see fnmatch docs for glob wildcards ). You can just do: for filename in glob.glob("pc[23456]??.txt"): If you need to be extra specific that the two trailing characters are numbers (some files might have non-numeric characters there), you can replace the ? s with [0123456789] , but otherwise, I find the ? a

Opencv: Why does the file size change when I read and write an image without making any changes?

淺唱寂寞╮ 提交于 2019-12-06 04:46:37
I have a list of (.TIFF) files which I am renaming and saving in the same format. I am using cv2 module to do this. import cv2 import os import glob os.chdir('C:/99_Temp/') for file in glob.glob("*.tiff"): f = os.path.splitext(file) time_val = f[0][:2] a1 = cv2.imread(file) cv2.imwrite(time_val+'.tiff',a1) Why are the file sizes reduced from the original TIFF file? I haven't done any processing and visually the images look the same. But I am wondering, why the difference? There could be many explanations of why the size of a TIFF file changes. Here are a few: one file may be RGB with 3 bytes

How to define multiple patterns in php glob()

孤者浪人 提交于 2019-12-06 04:10:01
My code to get all images from a directory $dirname = "uploads/"; $images = glob("{$dirname}*.png, {$dirname}*.jpeg, {$dirname}*.jpg, {$dirname}*.gif"); foreach($images as $image) { echo "<img src='{$image}' class='files_main'>"; } This works for one type of image but fails with multiple please give the syntax of defining multiple patterns in the glob(). You can use the GLOB_BRACE constant GLOB_BRACE - Expands {a,b,c} to match 'a', 'b', or 'c' e.g. $dirname = 'uploads/'; glob("$dirname*.{png,jpeg,jpg,gif}", GLOB_BRACE); See: http://php.net/manual/en/function.glob.php 来源: https://stackoverflow