glob

Brace expansion in python glob

谁说胖子不能爱 提交于 2020-02-01 12:17:12
问题 I have python 2.7 and am trying to issue: glob('{faint,bright*}/{science,calib}/chip?/') I obtain no matches, however from the shell echo {faint,bright*}/{science,calib}/chip? gives: 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

Brace expansion in python glob

你说的曾经没有我的故事 提交于 2020-02-01 12:16:26
问题 I have python 2.7 and am trying to issue: glob('{faint,bright*}/{science,calib}/chip?/') I obtain no matches, however from the shell echo {faint,bright*}/{science,calib}/chip? gives: 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

Perl glob strange behaviour

最后都变了- 提交于 2020-01-30 06:00:06
问题 I have a piece of perl code: if (glob("$data_dir/*$archivefrom*")) { my $command1 = "zip -r -T -m $backup_dir/$archivefrom.zip $data_dir/*$archivefrom*"; my $err_cmd1 =system("$command1"); if ($err_cmd1 != 0){print "Error $command1\n";exit 1;} } sometimes the if returns true but the zip would not match anything, why would that happen? There is no concurrent processes that would remove files in the meantime, it's just glob is returning something different from zip archive match for files, it

List files on SFTP server matching wildcard in Python using Paramiko

孤街醉人 提交于 2020-01-29 16:56:05
问题 import paramiko client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect('hostname', username='test1234', password='test') path = ['/home/test/*.txt', '/home/test1/*.file', '/home/check/*.xml'] for i in path: for j in glob.glob(i): print j client.close() I am trying to list the wildcard files on remote server by using glob.glob . But glob.glob() is not working. Using Python 2.6. Remote server contains these files: /home/test1/check.file , /home

Why do glob.glob and pathlib.Path.glob treat hidden files differently?

那年仲夏 提交于 2020-01-24 02:20:31
问题 Consider this folder containing two files: test/ foo .bar Calling glob.glob('*') on this folder won't list the hidden .bar file: >>> glob.glob('test/*') ['test/foo'] But pathlib.Path.glob('*') will: >>> list(Path('test').glob('*')) [PosixPath('test/.bar'), PosixPath('test/foo')] I'd like to know if this is intended or possibly a bug/oversight. The glob module documentation states that files starting with a dot are special cased: glob treats filenames beginning with a dot (.) as special cases

What's the difference between * and .* in regular expressions?

自作多情 提交于 2020-01-23 17:37:08
问题 I saw the wildcard of * been used in some command like: find *.jpg , which means find any files ended with .jpg . However, in regular expressions, .* also means that 0 or more times for any character. So, what's the difference between them? When is * been used and when is .* ? 回答1: In regular expressions, * is the "zero or more" repetition marker. . is the "any single character (with caveats)" expression. In a find the * character is an "anything" wildcard and is not really a regular

Prevent globbing after variable substitution

自闭症网瘾萝莉.ら 提交于 2020-01-22 21:29:46
问题 What is the most elegant way to use shell variable (BASH) that contain characters reserved for globbing (filename completion) that trigger some unwanted substitutions? Here is the example: for file in $(cat files); do command1 < "$file" echo "$file" done The file names contain characters like '[' or ']'. I have basically two ideas: 1) Turn off globbing via set -f: I need it somewhere else 2) Escape the file names in files: BASH complains about "file not found" when piping into stdin Thx for

Bizarrer perl behavior with glob [duplicate]

[亡魂溺海] 提交于 2020-01-15 05:41:33
问题 This question already has answers here : Why does Perl's glob return undef for every other call? (3 answers) Closed 5 years ago . use strict; use warnings; #only linux #use diagnostics; # - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - sub in_function { my $file = shift; glob($file) or die ("$file file was not found\n"); #this fails second time called # this is ok second time called #my @dummy = glob($file) or die ("$file file was not found\n"); } # - - - - - - - - - - -

Get filenames using glob

守給你的承諾、 提交于 2020-01-14 19:15:39
问题 I am reading several tsd files using panda and combine them to a big frame. I am using glob to iterate trough all the files in my directory and sub-directories. Every single frame gets a unique key. Now I want to create a reference table where the file name to each key is stored. But since I don't really understand glob I don't know how to get only the names of the files. p = Path('myPath') data = [] reference_table = {} number_of_files = 0 for tsd_files in p.glob('**/*.tsd'): data.append(pd

Get filenames using glob

ε祈祈猫儿з 提交于 2020-01-14 19:11:08
问题 I am reading several tsd files using panda and combine them to a big frame. I am using glob to iterate trough all the files in my directory and sub-directories. Every single frame gets a unique key. Now I want to create a reference table where the file name to each key is stored. But since I don't really understand glob I don't know how to get only the names of the files. p = Path('myPath') data = [] reference_table = {} number_of_files = 0 for tsd_files in p.glob('**/*.tsd'): data.append(pd