Questions tagged [glob]

16 questions
16
votes
5 answers

Can I select only one result from a bash glob?

I'm trying to write a script for work to automate some reporting on an output. The Log files are (currently, it's being 'standardise' in the future) stored in this sort of path…
AncientSwordRage
  • 1,714
  • 1
  • 20
  • 26
9
votes
1 answer

Curly Brace glob order?

If I have two files (in a folder with similarly numbered files) such as foo.18 foo.19 And I want to use a glob on them, do I do it like so: cp -r /folder1/*.{19,20} /folder2/ or like so? cp -r /folder1/{*.19,*.20} /folder2/ Neither seem to expand…
AncientSwordRage
  • 1,714
  • 1
  • 20
  • 26
9
votes
2 answers

Bash globbing and argument passing

I have the following simplified bash script #!/bin/bash files=("$@") if [ "X$files" = "X" ]; then files=$HOME/print/*.pdf; fi for file in "${files[@]}"; do ls "$file"; done If I pass arguments (file names) as parameters this script will…
highsciguy
  • 2,534
  • 4
  • 21
  • 29
8
votes
1 answer

How to use parameter substitution in glob pattern (zsh)

I want to process a bunch of files ending in some suffixes, so I wrote the following zsh script but it did not work. EXT=(.jpg .png .gif) EXT=${(j.|.)EXT} # EXT becomes '.jpg|.png|.gif' for f in *($EXT); do # should become '*(.jpg|.png|.gif)'…
7
votes
3 answers

Force Bash 4 'globstar' option to ignore symlinks

Bash 4 has a fantastic option called 'globstar' that emulates (i.e. was stolen from) zsh's ** syntax for globbing across multiple directories. However, it's somewhat crippled (for my usage, at least) by the fact that it always follows symlinks. Is…
Kyle Strand
  • 719
  • 7
  • 15
6
votes
1 answer

"globbing" (*) comes from "global command"... Huh?

According to legend, in the early days what we now call "globbing" (i.e. using expressions like e.g. *.c, ./*.p?) was supported by one certain program /etc/glob, whose name in turn derived from "global command"... I don't know about you, but for me,…
kjo
  • 14,779
  • 25
  • 69
  • 109
6
votes
2 answers

How does logrotate treat globbing?

If I have a logrotate config file like this, # matches multiple ones /var/log/project/*.log { ... prerotate ... endscript ... } So how does the glob work here? If I have 3 log file matches that pattern, would the prerotate…
daisy
  • 53,527
  • 78
  • 236
  • 383
6
votes
1 answer

Why two almost idetical grep commands return different output: w/o and with filename

I have 2 almost identical greps: [Alex@localhost tmp]$ grep /bin/bash /etc/passwd root:x:0:0:root:/root:/bin/bash AlexL:x:500:500::/home/AlexL:/bin/bash user1:x:501:501:user1 12345:/home/user1:/bin/bash vs. [AlexL@localhost tmp]$ grep /bin/*sh…
ALZ
  • 921
  • 2
  • 10
  • 13
5
votes
2 answers

Modifying zsh globbing patterns to use with cp

I'm trying to write a script to copy files recursively from a particular folder except files A.extn, B/*.extn and C/* where B and C are directories and extn is just some generic extension. This is what I have: #!/usr/local/bin/zsh setopt…
5
votes
3 answers

Full path in glob in Zsh

Say I run the following on /some/path: for x in foo/*; do print $x done Are there any parameters I can use to tell Zsh to print, not just the filename, but the full absolute path to $x? (without explicitly hard-coding /some/path in the print…
Josh
  • 1,694
  • 3
  • 16
  • 32
4
votes
2 answers

Bash's declare -p HISTIGNORE brings bash to a halt! Why?

Executing the following code in GNU bash, Version 4.2.45(1)-release (x86_64-redhat-linux-gnu), Fedora 19 ... shopt -s extglob export HISTIGNORE="!(+(!([[\:space\:]]))+([[\:space\:]])+(!([[\:space\:]])))" declare -p HISTIGNORE ... brings bash to a…
Tim Friske
  • 2,190
  • 3
  • 23
  • 36
2
votes
1 answer

Specifying full range of printable ASCII characters in a glob pattern

I want to use a globbing pattern to match only printable (including space) ASCII characters 0x20 through to 0x7e. This is being used inside a super super.tab database. I've arrived at the pattern: [[ -~]] This appears to work and does indeed…
Kev
  • 1,429
  • 7
  • 21
  • 32
2
votes
1 answer

Does * match hidden files in tar even with dotglob unset?

I was under the impression that the * glob does not match dot-prefixed files unless you manually enable such functionality (through dotglob, or your shell's equivalent). Yet if I have a directory a containing files file1 and .hidden1, then if I…
fpghost
  • 727
  • 2
  • 8
  • 21
1
vote
1 answer

I quite like mercurial .hgignore-style globbing. Is there a Linux shell that supports it?

I quite like mercurial .hgignore-style pattern globbing. Globs are rooted at the current directory; a glob such as *.c will only match files in the current directory ending with .c. The supported glob syntax extensions are ** to match any string…
Serge Stroobandt
  • 2,314
  • 3
  • 32
  • 36
1
vote
1 answer

Filter / select folders using wildcards

For my mecurial ignore file I want to select all the folders that start with dataset in my project folder with with one 'glob statement'. Example project folder: my_project_folder/ dataset1/ dataset2/ dataset3/ code.py I tried dataset*/…
Framester
  • 1,633
  • 4
  • 18
  • 17
1
2