Questions tagged [globbing]

Globbing is a way to match sets of paths without explicitly specifying paths. For example, the * glob would match all paths in a directory.

Filter by
Sorted by
Tagged with
1
vote
1answer
33 views

bash: list files by mask and avoid unmatched masks

There is my script (simplified): cd /etc; for f in *.{conf,cfg,foo}; do echo $f; done It outputs something like adduser.conf apg.conf ... vdpau_wrapper.cfg *.foo (just an example) Just for now I ...
0
votes
1answer
29 views

How to match whitespace in the string with bash?

ls Session 9 - Terminal Value.mp4 Now i want to delete it. shopt -s dotglob rm -rf .*.mp4 It take no effect,the file Session 9 - Terminal Value.mp4 remains there.Maybe . can't match whitespace.
0
votes
1answer
45 views

Is there a bash setting to auto escape asterisks (*) if it is connected with a string?

I am trying to debug why a script didn't do what I wanted on my server. And while testing I found a curiosity. I have a directory that looks roughly like this: bash-4.3# ls -l ./ total 0 -rw-r--r-- ...
1
vote
1answer
87 views

ZSH: glob with prefix

Is it possible to add a 'prefix' to the shell glob expansion? My use case is the following, I have a program which requires repeating the option flag to pass multiple files as input: $ ls foo.txt bar....
0
votes
1answer
31 views

Deleting all subdirs except ones that match a certain pattern

I would like to delete all sub-directories and files in a given directory except directories that match a certain pattern: example_dir/model-*/gen-*/share/** General setup: I generated several ...
0
votes
1answer
157 views

Dynamically Change Watch Directories for Inotify

Thanks for any help in advance! I have set up an inotifywait script to monitor some applications for configuration changes. I am globbing to create all of the directories to watch; however, if there ...
1
vote
0answers
1k views

What are all of the globs I can use with grep in bash?

Linux and Unix-like shells like bash allow for the use of globs to approximate filenames and make file searching easier. I'm aware of the wildcard glob (*). What other globs exist in bash that I can ...
3
votes
1answer
84 views

Filename generation from variable in zsh without spawning subshell

In zsh I have a glob pattern in a variable, and I want to define another variable that performs filename generation on that pattern. Is there a way to do this without spawning a subshell? The ...
0
votes
1answer
63 views

Count and move files by pattern

I have many epub files I'm trying to organise into folders. All of my files named following the same pattern "Author - Name (Year).epub". What I'm trying to archive is to count files by authors and ...
4
votes
2answers
468 views

How do I make bash's glob character classes case-sensitive?

I had created some files like knob_A.png and knob_a.png and my teammate on Windows said this caused problems with her app. I decided to call it knob_W.png instead of knob_a.png. Then I did an rsync ...
0
votes
1answer
274 views

How to use globstar on bash older than v4

We use this command to run all tests using mocha: mocha ./src/test/**/*.js --recursive Notice the double **. It works fine on any modern bash, except on the CI system which is a RedHat with GNU bash, ...
-1
votes
1answer
86 views

LInux-File Globbing

I have an assignment and it asks me to Display files in /usr/bin that do not begin with a through v it then asks me to Display files in /usr/bin that contains at least two numeric digits I've ...
4
votes
1answer
816 views

Filenames having square brackets, NOT ignored by .gitignore?

Editor1CurrentlyOpen[1].txt Since regex is not effective in the .gitignore file, how can a glob encompass filenames such as the above?
1
vote
1answer
179 views

Order of files matched by a glob

Suppose I have the following files in a folder 1.txt 2.txt a.txt b.txt c.txt If I match those files by a glob in order to process them, e.g. for f in *;do echo $f;done then Bash will match them - ...
2
votes
2answers
2k views

How can I expand both a variable name and a wildcard in a file name?

I have a bash script where $DIR is a directory name that may contain spaces. This: rm "$DIR/*.MOV" gives the error "No such file or directory". There is no file literally named "*.MOV"; I want the *...
1
vote
1answer
2k views

Linux tar files within specific date range using filename date

I have files whose names begin with YYYYMMDD like the following: 20160221_143223_Report.csv 20160222_121223_Report.csv ... 20160229_141223_Report.csv 20160301_171223_Report.csv I want to ...
1
vote
0answers
57 views

How to target directory above with pattern glob

How can i create a pattern for directories that are one level above? Say i'm in /dir/server/ and i want to match /dir/src/? I need to modify this glob: '!{app.js,{src,common,lib}/**}' but eg. '!{...
2
votes
2answers
4k views

Remove files from a root-owned directory using sudo with wildcards

Let's say I have a folder, /var/log/nginx which is protected (owned by root, and no one else can read or write into it). Even using sudo, I can't do sudo rm -f /var/log/nginx/ab* without getting "No ...
3
votes
1answer
2k views

logrotate: How to configure and override defaults?

I'm testing a logrotate configuration in /tmp. I'd like to configure a default logrotate policy for /tmp/*.log files using my test configuration file /tmp/logrotate.conf to handle a particular log ...
5
votes
1answer
604 views

Bash partial glob expansion

I have a question similar to this one, but different: I want bash to use a glob expansion in auto-completion, if possible. For example, I would like $ ls *2.<TAB> To give me: $ ls mydoc2. ...
0
votes
1answer
708 views

Curl globbing (asterisk expansion) on windows

On windows, in git bash (but in system console too, I think) Why curl ignores all my attempts to disable globbing and expands asterisk? $ GLOBIGNORE="*"; set -f; curl --noproxy "*" "http://www....
3
votes
0answers
323 views

How do I write a Makefile target for hundreds of numbered files?

I have some art projects that use blender as part of the toolchain. I would like to be able to write a Makefile target which specifies that several hundred files can be updated with a single command. ...
3
votes
1answer
76 views

for breaks script execution in ZSH

I feel dumb. I have a ZSH script with eg two file loops, eg: for f (*aaa*) {echo "$f"} for f (*bbb*) {echo "$f"} The script exits if the first find does not find matching files. I need the script to ...
1
vote
1answer
68 views

Different globbing behavior with same shopts?

I have multiple shells (bash) open on the same machine, and in one of them, globbing seems to have stopped. ls * gives ls: *: No such file or directory, and so on. I figured that I must have set some ...
4
votes
2answers
3k views

How to exclude a file from a command with ZSH?

Given this directory content : one.file two.file three.file in bash, when I enter rm *.file !(two) only one.file and three.file are deleted. How can I do this in ZSH?
8
votes
2answers
3k views

Linux Bash Shell - File globbing specific range?

I have a bunch of files in a folder: spreadsheet700.xls spreadsheet800.xls spreadsheet850.xls spreadsheet1005.xls spreadsheet2400.xls how can I use file globbing to select files that numbers end in ...
9
votes
3answers
20k views

How to delete all hidden .swp files from terminal

How can I delete all .swp files? I tried rm *.swp but I got rm: *.swp: No such file or directory rwxr-xr-x 16 teacher staff 544 Jan 17 13:19 . drwxr-xr-x 19 teacher staff 646 Jan 16 12:48 .....
0
votes
1answer
455 views

zshell globing works for ls, but not scp

Note: This problem is with zshell, it works with bash. I have some images: $ ls *.jpg a.jpg b.jpg But when I try to copy them with scp, it says there are none: $ scp *.jpg host: *.jpg: No such ...
5
votes
1answer
1k views

Exclude directories in ZSH glob

With zsh, you can use **/* as a short alternative to using find. Is there any way to restrict that to regular files, that is an equivalent to the -type f option?
0
votes
1answer
358 views

How do bash scripts expand file globs?

In this code, the excludespec variable is expected to match all it substring, but it appears to evaluate the to the actual files matching it when it is executed, rather than pass its exact ...
7
votes
2answers
3k views

how to handle bash * matching when there are no matches?

The following bash snippet works great when there are actually *.txt files in the directory. for txt in *.txt do echo "loading data from $txt" done ...
4
votes
1answer
1k views

rdiff-backup fails from shell script

I am trying to run a shell (sh) script for backups, using rdiff-backup. The lines of interest are: cmd="${prog} -v5 --print-statistics --include-globbing-filelist ${inclist} \ --exclude ** ${src} ${...
1
vote
0answers
120 views

How do I get zsh tab completion to “vi **/foo<TAB>” to match and complete the first file matching “foo*” anywhere under the current directory?

How do I get zsh tab completion to cat **/foo<TAB> to match and complete the first file matching foo* in any subdirectory under the current directory? For example, do this while inside a fresh ...
2
votes
1answer
1k views

Bash filename tab completion

I have noticed sometimes that tab completion is helpfully filtered in bash. I am a java programmer and often use the java and javac commands in the terminal for quick or remote tasks. Say I have the ...
2
votes
2answers
400 views

Cat command output varies unusually in regards to * character

I'm running the following command on a fairly standard Ubuntu 11.04 installation running under vSphere: sudo cat /home/*/.ssh/authorized_keys Basically, I am using puppet for ssh key management and ...
3
votes
1answer
414 views

can I make zsh filename completion work like Vim?

I use setopt menu_complete so that I can hit TAB repeatedly to get different filename completions in zsh. However, I would also like to be able to type: ls ~/*.txt<TAB> and then use TAB to ...
0
votes
1answer
68 views

Is it possible to permutate shell globbing expressions?

When using normal shell globbing, * often matches files in lexicographic order. For certain reason, sometimes I don't want this behavior. Is there a way to scramble matching results so their order is ...
18
votes
1answer
8k views

how do I correctly negate zsh globbing expressions?

I want to list all files but those ending with owp: Hence I tried: ls -l *.(^owp) zsh: unknown sort specifier ls -l *(^owp) zsh: unknown sort specifier ls -l *[^o][^w][^p] # does not work ...
3
votes
1answer
1k views

How do I get zsh's autocomplete to complete wildcards like bash does?

In zsh and in bash, if I type ls c<TAB> it displays every filename starting with c. If instead I type ls c*<TAB>, bash behaves the same way, but zsh replaces the c* with the list of every ...
7
votes
5answers
2k views

How to use _one_ shell globbing expression to list all files (of course hidden files too!)?

Ok, this question targets at Unix/Linux shells! I want a shell globbing- (aka wildchard-) expression that matches all files including hidden files in current directory non-recursively (maxdepth == 1). ...
0
votes
0answers
157 views

How to list files ending with .sh only? [duplicate]

Possible Duplicate: How to use grep to see only Listed Files in a directory I have many files in a folder, for example: Kiran.txt Kiran1.txt Kiran221.txt Kiran144.txt Time.csv Timer.csv Timer2....
3
votes
4answers
26k views

How to list files based on matching only part of their filename?

I have many files in a folder for example Kiran.txt Kiran1.txt Kiran221.txt Kiran144.txt Time.csv Timer.csv Timer2.csv Timer444.csv Timer266.csv Account.sh Account3.sh Account3333.sh Account3333.sh ...
0
votes
2answers
979 views

File matching pattern on command line?

Can someone help me with a relatively complex command-line file matching pattern? I've got files in a directory as follows: 1.png 1_thumb.png 1-1.png 1-1_thumb.png 1-2.png 1-2_thumb.png 2.png ...
6
votes
1answer
4k views

Does a wildcard inside double-quotes glob? [closed]

On a "standard BASH" does a wildcard inside double-quotes glob? For example: $ touch abc $ ls "*abc*" would that, or wouldn't that work on bash? I was told Ubuntu shipped with a bash variant that ...
1
vote
1answer
273 views

Is it possible to use brace expansion and globbing together?

Say I wanted to copy the .ssh/authorized_keys file in each user's /home directory to /tmp (for whatever reason). I figured I could use globbing and brace expansion to do this quickly, but I ran into ...
5
votes
2answers
8k views

“ls” or regex is case insensitive?

In bash, I tried ls [a-z]* and expected to list all the files with filename starts with small case alphabet. But why the files with name starts with big case alphabet are also shown? >ls [a-z]* ...
34
votes
5answers
8k views

How to expand * on Bash command line

I understand that if you type ls * it is actually expanded to ls a b c when the current directly has files a, b and c. I was wondering if there is a way to expand this before I hit enter. Similar to ...
24
votes
2answers
6k views

Does bash's * match files in alphanumeric order?

I want to concatenate a bunch of files together in filename order. Is it safe to assume that this will give me them in alphanumeric order? cat * i.e. the same order that ls gives.
20
votes
6answers
34k views

Will rm -rf * remove all files/folders in the current directory?

Will rm -rf * remove all files/folders in the current directory ? I want to make sure the wildcard * won't move up in upper directories and erase all my filesystem. :D I remember doing chmod 777 .* -...