glob

grep filename[asterisk] returns unexpected result

点点圈 提交于 2019-12-22 17:46:40
问题 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? 回答1: 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

How to use basic regular expressions within gulp.src?

时间秒杀一切 提交于 2019-12-22 07:11:11
问题 I'm trying to select two files with gulp.src : highcharts.js and highcharts.src.js . Of course I know I could add explicitly these two with an array expression, but for learning purposes I'm trying to write a single expression for them. I've read that one can use simple regular expression syntax but it's not clear how. I tried gulp.src("highcharts(\.src)?\.js") but it didn't match any files. 回答1: Gulp uses glob which doesn't support the regular expressions you're normally used to. It uses

Gulp glob to ignore file types and not copy empty folders

别说谁变了你拦得住时间么 提交于 2019-12-22 06:25:10
问题 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

Gulp glob to ignore file types and not copy empty folders

梦想与她 提交于 2019-12-22 06:23:05
问题 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

Gulp copying empty directories

一曲冷凌霜 提交于 2019-12-22 04:25:28
问题 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. 回答1: Fixed it by adding a filter to the

pagination of php glob page

为君一笑 提交于 2019-12-22 00:52:38
问题 i have a page that uses glob to display images that is inside a folder. The thing is, i want to display only 20 pics per page. The tutorials about pagination that i found online is related with database, but i did not use database inside my code. $files = glob("uploaded_files/*.*"); usort($files, function ($a, $b) { return filemtime($b) - filemtime($a); }); foreach ($files as $file) { echo "<img src='$file' style='height:180px;width:180px; border:2px solid black; margin:20px 0px 10px 10px;

How to match nothing if a file name glob has no matches [duplicate]

送分小仙女□ 提交于 2019-12-21 07:25:30
问题 This question already has answers here : How to skip the for loop when there are no matching files? (2 answers) Closed 6 months ago . I want to loop over all files matching extension jpg or txt . I use: for file in myDir/*.{jpg,txt} do echo "$file" done Problem: If the directory contains no jpg file at all, the loop will have one iteration with output myDir/*.jpg . I thought * will be replaced by an arbitrary file (and if no file exists it cannot be expanded). How can I avoid the unwanted

how to `git ls-files` for just one directory level.

浪子不回头ぞ 提交于 2019-12-21 03:33:27
问题 I'm using msysgit (1.7.9), and I'm looking for the right invocation of the git ls-files command to show just the (tracked) files and directories at the current level, either from the index, or the current working directory if that's easier. Essentially it would give a directory listing similar that that you would see on Github. Coming from Windows, I'm not too familiar with the right way of doing the globbing(?). 回答1: I think you want git ls-tree HEAD sed'd to taste. The second word of ls

cmake glob include while preserving directory structure

佐手、 提交于 2019-12-21 03:33:25
问题 I'm new to cmake and I'm trying to install .hpp files while preserving directory structure. So far I have FILE(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/include/MyLib/*.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/include/MyLib/detail/*.hpp" install (FILES ${files} DESTINATION include) All the files get found but the directory hierarchy is flattened. FWIW The bjam command I'm trying to emulate is install headers : ../include/EnsembleLearning.hpp [ glob ..

Why am I leaking memory with this python loop?

别说谁变了你拦得住时间么 提交于 2019-12-20 12:24:04
问题 I am writing a custom file system crawler, which gets passed millions of globs to process through sys.stdin. I'm finding that when running the script, its memory usage increases massively over time and the whole thing crawls practically to a halt. I've written a minimal case below which shows the problem. Am I doing something wrong, or have I found a bug in Python / the glob module? (I am using python 2.5.2). #!/usr/bin/env python import glob import sys import gc previous_num_objects = 0 for