标签: glob

节点/ JavaScript glob文件/路径匹配语法,通配符等

我刚刚找到了http://gruntjs.com/configuring-tasks#globbing-patterns,这是我发现的最有用的参考资料.

我一直看到:

有关glob模式语法的更多信息,请参阅node-glob和minimatch文档.

然而,我似乎找不到详尽的语法/用法列表. 这些测试可能是最好的参考,但仍然不是特别容易破译.

看来我必须缺少一些重要的文档来源.

我想知道之间的区别:

path
path/
path/*
path/*.*
path/**
path/**/
path/**/*
path/**/*.*
Run Code Online (Sandbox Code Playgroud)

以及我可能省略的任何其他重要变化.我猜这在做node-glob样式匹配('public/**/*.*')和a .gitignore(node_modules)时应用的方式不同,因为在前者中,你需要明确地包含所有东西,很多层深,而在gitignore中,这是通过忽略任何目录自动处理的.它是否正确?

javascript glob node.js

15
推荐指数
1
解决办法
1万
查看次数

cmake glob包括保留目录结构

我是新手cmake,我正在尝试.hpp在保留目录结构的同时安装文件.

到目前为止我有

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)
Run Code Online (Sandbox Code Playgroud)

找到所有文件但目标层次结构已展平.

FWIW bjam我试图模仿的命令是

install headers 
    : ../include/EnsembleLearning.hpp  
      [ glob ../include/MyLib/*.hpp ]  
      [ glob ../include/MyLib/detail/*.hpp ]  
    : <install-source-root>../include ;
Run Code Online (Sandbox Code Playgroud)

c++ install glob directory-structure cmake

14
推荐指数
1
解决办法
5495
查看次数

glob() - 按名称排序

如何按文件名反转排序?目前它按字母/数字顺序显示所有文本文件,但我试图让它以降序显示.现在,我有......

<?php  
foreach (glob("*.txt") as $filename) {
   include($filename);
}
?>
Run Code Online (Sandbox Code Playgroud)

我是PHP的新手,但是我尝试使用添加的数组,但只是导致它只显示了一个文本文件,所以要么不起作用,要么我编写错了.

php sorting foreach reverse glob

14
推荐指数
2
解决办法
2万
查看次数

带有Dir ['*']的Ruby列表目录,包括dotfiles但不包括.和

我如何Dir['*']包含dotfiles,例如.gitignore,但不是...

即,有更好的方法吗?

`ls -A`.split "\n"
Run Code Online (Sandbox Code Playgroud)

或许与Dir?以下解决方案很接近,但都包括.&..:

Dir.glob('*', File::FNM_DOTMATCH)
Dir['{.*,*}']
Run Code Online (Sandbox Code Playgroud)

所以,以下工作:

Dir.glob('*', File::FNM_DOTMATCH) - ['.', '..']
Run Code Online (Sandbox Code Playgroud)

但是,还有更好的方法吗?

我想知道如何修复Meteor Homebrew Formula的第9行.

ruby glob file dir dotfiles

14
推荐指数
1
解决办法
4716
查看次数

在python glob中支持扩展

我有python 2.7,我试图发出:

glob('{faint,bright*}/{science,calib}/chip?/')
Run Code Online (Sandbox Code Playgroud)

我没有获得匹配,但是从shell echo {faint,bright*}/{science,calib}/chip?给出:

faint/science/chip1 faint/science/chip2 faint/calib/chip1 faint/calib/chip2 bright1/science/chip1 bright1/science/chip2 bright1w/science/chip1 bright1w/science/chip2 bright2/science/chip1 bright2/science/chip2 bright2w/science/chip1 bright2w/science/chip2 bright1/calib/chip1 bright1/calib/chip2 bright1w/calib/chip1 bright1w/calib/chip2 bright2/calib/chip1 bright2/calib/chip2 bright2w/calib/chip1 bright2w/calib/chip2
Run Code Online (Sandbox Code Playgroud)

我的表情有什么问题?

python bash shell glob expansion

14
推荐指数
3
解决办法
3611
查看次数

使用PHP glob获取文件夹 - 深度不受限制

我有这个工作函数,找到文件夹并创建一个数组.

function dua_get_files($path)
{
    foreach (glob($path . "/*", GLOB_ONLYDIR) as $filename)
    {
        $dir_paths[] = $filename;   
    }
    return $dir_paths;
}
Run Code Online (Sandbox Code Playgroud)

此功能只能查找当前位置的目录.我想在子文件夹及其子文件夹中找到目录路径,依此类推.

该数组仍应是目录路径的平面列表.

输出数组应如何显示的示例

$dir_path[0] = 'path/folder1';
$dir_path[1] = 'path/folder1/child_folder1';
$dir_path[2] = 'path/folder1/child_folder2';
$dir_path[3] = 'path/folder2';
$dir_path[4] = 'path/folder2/child_folder1';
$dir_path[5] = 'path/folder2/child_folder2';
$dir_path[6] = 'path/folder2/child_folder3';
Run Code Online (Sandbox Code Playgroud)

php directory foreach glob

13
推荐指数
3
解决办法
2万
查看次数

如何在$ node中获取html而不仅仅是$ nodeValue

目前情况说明:

我有一个充满页面的文件夹(pages-folder),该文件夹中的每个页面都有(除其他外)一个div id="short-info".
我有一个代码<div id="short-info">...</div>从该文件夹中提取所有内容并使用textContent(显示为此目的nodeValue)显示其中的文本

加载div的代码:

<?php
$filename = glob("pages-folder/*.php");
sort($filename);
foreach ($filename as $filenamein) {
    $doc = new DOMDocument();
    $doc->loadHTMLFile($filenamein);
    $xpath = new DOMXpath($doc);
    $elements = $xpath->query("*//div[@id='short-info']");

        foreach ($elements as $element) {
            $nodes = $element->childNodes;
            foreach ($nodes as $node) {
                echo $node->textContent;
            }
        }
}
?>
Run Code Online (Sandbox Code Playgroud)

现在的问题是,如果我加载的页面有一个子项,如图像:<div id="short-info"> <img src="picture.jpg"> Hello world </div>,输出将只是Hello世界而不是图像,然后是Hello world.

题:

如何使代码在div id ="short-info"中显示完整的html,包括例如图像而不仅仅是文本?

php dom glob nodevalue

13
推荐指数
1
解决办法
1万
查看次数

PHP代码使用glob排除index.php

问题

我试图从一个名为../health/的文件中显示一个随机页面.在这个文件中有一个index.php文件和118个其他名为php文件的文件.我想从健康文件夹中随机显示一个文件,但我希望它排除index.php文件.

以下代码有时包含index.php文件.我也尝试改变$ exclude行来显示../health/index.php,但仍然没有运气.

<?php
$exclude = array("index.php"); // can add more here later
$answer = array_diff(glob("../health/*.php"),$exclude);
$whatanswer = $answer[mt_rand(0, count($answer) -1)];
include ($whatanswer);
?
Run Code Online (Sandbox Code Playgroud)

我尝试过的另一个代码如下

<?php
$exclude = array("../health/index.php"); // can add more here later
$health = glob("../health/*.php");
foreach ($health as $key => $filename) {
foreach ($exclude as $x) {
if (strstr($filename, $x)) {
unset($whathealth[$key]);
}
}
}
$whathealth = $health[mt_rand(0, count($health) -1)];
include ($whathealth);
?>
Run Code Online (Sandbox Code Playgroud)

此代码还包括index.php文件,而不是显示它将页面显示为错误的页面.

php arrays glob

13
推荐指数
2
解决办法
7657
查看次数

.gitignore遵循什么模式?

这是我当前目录的内容.

$ ls
foo.foo
$ ls -a
.  ..  .bar.foo  .foo  foo.foo  .gitignore
Run Code Online (Sandbox Code Playgroud)

然后我将此目录转换为git存储库.

$ git init
Initialized empty Git repository in /home/lone/foo/.git/
$ ls -a
.  ..  .bar.foo  .foo  foo.foo  .git  .gitignore
Run Code Online (Sandbox Code Playgroud)

这是内容.gitignore.

$ cat .gitignore 
*.foo
Run Code Online (Sandbox Code Playgroud)

我看到模式的.gitignore行为与shell中的相同模式不同.在shell *.foo中只匹配非隐藏文件,即不以句点开头的文件名.

$ echo *.foo
foo.foo
Run Code Online (Sandbox Code Playgroud)

但是,*.foo.gitignore似乎匹配任何文件,隐藏或不隐藏,随结束.foo.

$ git status
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .gitignore

nothing added …
Run Code Online (Sandbox Code Playgroud)

git shell glob

13
推荐指数
1
解决办法
819
查看次数

Pattern match does not work in bash script

Using the pattern match !("file1") does not work within a bash script but will work on the command line.

For example:

ls  !("file1"|"file2")
Run Code Online (Sandbox Code Playgroud)

This will list all files in directory except file1 and file2.

When that line is executed in a script this error is displayed:

./script.sh: line 1: syntax error near unexpected token `('
./script.sh: line 1: ` ls  !("file1"|"file2") ' 
Run Code Online (Sandbox Code Playgroud)

Regardless what is used rm -v !("file1"). The same error takes place. What is going on …

linux bash glob extglob

13
推荐指数
2
解决办法
469
查看次数