Questions tagged [wildcards]

Globbing means matching files by name patterns containing wildcards.

Filter by
Sorted by
Tagged with
7
votes
5answers
912 views

Using wildcards to elegantly convert thousands of epub files to mobi

I am executing the below command for 1000 files: ebook-convert <name-of-first-file>.epub <name-of-first-file>.mobi ebook-convert <name-of-second-file>.epub <name-of-second-file>...
0
votes
1answer
40 views

Event not found in shell expansion [duplicate]

$ touch fux fax fix $ ls f[!a]x zsh: event not found: a]x I want to see fix and fux as output, but not fax. I want to know the exact reason behind this issue. Is this particular issue regarding the ...
0
votes
2answers
50 views

Use ls to list backup files only

I have a large number of "backup" files of the form '#e.xvg.i#', where i ranges from 1 to 60. A file e.xvg also exists in the same directory. For example: e.xvg '#e.xvg.1#' '#e.xvg.2#' ... ...
1
vote
2answers
57 views

Why the cache directory gets deleted if not "*" is specified?

I have ZSH as my default shell and I am using OhMyZsh on top of it. Some times I need to delete some files and reset some permissions/ownership so I am working in an alias for it. Lets say I have a ...
-1
votes
2answers
51 views

Syntax to select a group of files based on extension?

I have several files in the following form, Group - 1 file1.n001 file2.n002 file3.n003 file4.n004 : : : filex.nx Group - 2 file1.ntemp file2.nreal : :etc In order to remove only files, with ...
4
votes
1answer
105 views

Partially resolve/follow symlinks when globbing in zsh/Bash

Assume I have a file a which is a symlink to b, which in turn is a symlink to c. With zsh's :A modifier, globbing a will result in an absolute path, resolving all symlinks, hence a(:A) will expand to ...
0
votes
1answer
33 views

Escape slashes when sending command output to an array [duplicate]

In my current project, I am trying to take the output from git branch -r to an array in zsh, as follows: % all_branches = ("${(@f)$(git branch -r)}") However, when I run this command, I get ...
1
vote
1answer
43 views

Passing arguments into a glob pattern within a script

I have a script called get_numbers.sh, which I want to use to extract data from .pdf files labelled sequentially by date, using pdfgrep. Let me simplify my problem to what I believe are its essentials:...
5
votes
1answer
260 views

/bin/sh: wildcard expansion does not work in script

I am using dash as /bin/sh. In my script, I have following line: SSH_AUTH_SOCK=/tmp/ssh-????????????/agent.* Which is supposed to match file /tmp/ssh-abcdefghijkl/agent.1234. Even when the file ...
0
votes
1answer
119 views

Using a wildcard with "killall" doesn't work other than from /tmp

I have /tmp/bash.sh that contains a script like this: killall name* It works fine if I go to /tmp folder and then run ./bash.sh, but if I go to / then run /tmp/bash.sh or ./tmp/bash.sh it doesn't ...
2
votes
1answer
35 views

rsync over ssh with multiple wildcards in bash while keeping directory structure

I have a directory structure like so on a remote server, listing some of the files below: /logs/service::A1/20210730T120000/log.log /logs/service::A1/20210729T120000/log.log /logs/service::A2/...
1
vote
1answer
62 views

Regular expressions and wildcards in `if` statements

I am using regular expressions and wildcards in if statements. Examples: [[ "$exitfn" =~ ^[yY]*$ ]] && return [[ "$exitfn" == "[yY]*" ]] && return [[...
2
votes
1answer
50 views

Create Symlink Glob of directory read from a file

I am extracting names of directory at 5th column of tsv file ExtensionList.tsv and I want to create symlinks to all those folders with names beginning with that located at ${HOME} inside Extension ...
0
votes
1answer
34 views

GNU Stow - is there any way to add file extensions to .stow-global-ignore or .stow-local-ignore files?

I want stow to ignore certain files, like *.bak and *.tmp, but I cannot seem to be able to add wildcards and get them to work. I have tried: *.bak *.tmp \*.bak \*.tmp I suppose wildcards are not ...
0
votes
1answer
61 views

How do I grep files with .mp3 but not .mp3.RegFr? [closed]

I have files ABC.mp3, ABC.mp3.RegFr. I want to grep files with .mp3 and not .mp3.RegFr. Can anybody help?
4
votes
2answers
251 views

How may I reuse an asterisk-globbed path in zsh?

My question and the title may not be very well-formed, and I apologise in advance for that. Suppose I would like to execute a command (to be specific, xsdcxx) as such in zsh: $ xsdcxx cxx-tree schemas/...
2
votes
1answer
117 views

Find file glob pattern or regex by name but allow for exact match at beginning and only certain characters at end

I am trying to match some image files which share a basic name but have sizing information appended to the end with find . -name 'Name*' to match files such as: Name.jpg Name@2x.jpg Name-180x101.jpg ...
6
votes
3answers
448 views

Checking if a subdirectory exists using glob in script

I'm trying to check if a directory bin is inside a directory which can sometimes change. In this particular case, the version number of ruby can change (e.g. $HOME/.gem/ruby/2.6.0/bin). Here's what I ...
1
vote
1answer
30 views

Making Linux unzip command just extract files from directories whose names contain a given string

I have a zip archive that contains a directory hierarchy of files. I want to use the Linux unzip command to extract just the subset of these files that have a particular string somewhere in the ...
0
votes
0answers
11 views

Copy certain file endings keeping folders with rsync [duplicate]

I want to use rsync to copy all files from subfolders with a specific file ending, keeping the folder structure at the destination. Given a folder structure, for example foo | bar | file1.txt ...
0
votes
0answers
25 views

Using bash wildcards with filenames that have single-quotes [duplicate]

I used wget within bash to download a bunch of files from a parameterized URL. My URL file looked something like this: http://www.example.com/Home/Sales?lrsn=48726 http://www.example.com/Home/Sales?...
0
votes
0answers
34 views

Matching paths to exclude from mv moving with bash globbing

I'm editing an install script to exclude a few directories from being installed, under the base directory, as they're already on the system, and I'll save about a gig doing this. I keep getting mv: ...
0
votes
0answers
9 views

gzip by glob with variable [duplicate]

When I use variable within glob expression like gunzip *_{${X}}.gz it does not work. Here is an example: [nir@etl-dev test]$ ll total 96 -rw-rw-r-- 1 nir nir 22431 May 6 10:35 a20210427_AA.gz -rw-rw-...
-1
votes
2answers
69 views

How does the this wildcard work "* .*"

Here are the outputs. echo *.* file1.txt file2.txt file3.txt echo * .* file1.txt file2.txt file3.txt . .. Why does the second command include the files if they have no space character before the ...
0
votes
3answers
111 views

Removing files from remote machine

I remove files with wildcard by rm /home/files/*.csv but when I try run the command on a remote machine via ssh as ssh user@ip 'rm /home/files/*.csv' it tries to delete *.csv file instead, and I get ...
1
vote
2answers
70 views

Explaining what this command does

ls *.txt | lp Wouldn't this command list all files that end in .txt and then print them?
-1
votes
1answer
33 views

Does fontconfig use Ant naming pattern for glob'bing?

If there's a foo font I manually downloaded with many directories in it, is it a correct way to include all of them? <fontconfig> <selectfont> <rejectfont> &...
3
votes
5answers
152 views

Group files and directories based on first letter of their name and move them to directories of that letter

I have a directory with the following content: $ mkdir dir && cd "$_" ~/dir $ mkdir a1 a2 a3 a4 b1 c1 c2 1a 2a 2b 2c 2d 3a _1 _2 ~/dir $ touch a_1 a_2 a_3 a_4 b_1 c_1 c_2 1_a 2_a 2_b ...
0
votes
1answer
65 views

How to use wildcards in execv without system or bash (in c)? [closed]

I would like to use char *argv[] = {"rm", "-r", "/home/banana/Quest/*/", NULL}; execv("/bin/rm", argv); in a C file to delete all directories in the Quest ...
1
vote
1answer
88 views

How do Bash and Zsh handle collation in patterns and regexes?

Consider the following example: $ bash --version GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later &...
0
votes
1answer
322 views

Using Ansible to fetch or copy files from a remote server (using globs) to the current server results in "file not found: /tmp/data/*.zip"

In Ansible, I want to fetch or copy zip files from remote server-B to currently logged remote server-A (both are Linux hosts).  As you can see below, I am specifying the source files with a wildcard (...
0
votes
0answers
21 views

How to shell glob in desktop shortcuts? [duplicate]

I wanted to make a desktop shortcut that performed an operation on multiple files matched by a wildcard pattern. However, it seems the desktop shortcut Exec option doesn't acknowledge globbing. For ...
0
votes
2answers
56 views

How to load more than 10 files with range in executable args? [duplicate]

I have this working command line expression: program --files path_to_mydir/mydata_[0-9].csv I would like to go from [0-100] but this is not working. program --files path_to_mydir/mydata_[0-100].csv ...
1
vote
1answer
94 views

Using alternation when matching filename globbing pattern

if [[ $1 == *.(png|jpg) ]] is what I've tried, and it doesn't work. I need to check if $1 matches one of those filename suffixes, so I can then do stuff with it. I'm not sure how to go about this. I'...
0
votes
1answer
41 views

Globing with linux

How do you list only files that have two numbers in the name? I did ls *[0-9]*[0-9]* but it appears that this is not the right one as it shows other files that have 4 digits in their name. How do you ...
0
votes
0answers
28 views

Delete a folder that does not match a pattern [duplicate]

I have two folders, one that I know the name of, and one that I don't: ~/foobar-as9df7 # I know the name of this one ~/foobar-7fq92h # I don't know the name of that one How can I delete the folder ...
0
votes
0answers
58 views

How to make --exclude-glob work with this use case of lftp and fish shell?

I have a statement that looks like this: set cmd 'set ssl:verify-certificate false; open -u abc,def ftp.somewhere.com; mirror --only-newer --exclude-glob "{.git|node_modules|wp-config.php}" \...
0
votes
1answer
242 views

syntax error near unexpected token

I'm running this command in jenkins, and it's using sh. However I'm not sure what this error means in my bash script #! /bin/sh for d in $(ls -d kube/xx/bb/!(abc*|!cdf*)/ | xargs -I {} basename {} ) ;...
5
votes
1answer
419 views

Can ** (bash's globstar) run out of memory?

Can using bash's globstar (**) operator cause an out of memory error? Consider something like: for f in /**/*; do printf '%s\n' "$f"; done When ** is being used to generate an enormous list ...
0
votes
2answers
25 views

Grep the RHS of the equal too sign [duplicate]

I am grepping into /etc/os-release and then I want to store the output in a variable. I had made a conditional script where I was not needing a variable but now I need one. [[ ${$(grep ID_LIKE /etc/os-...
6
votes
1answer
382 views

Bash expansion asymmetry when opening and creating files

I have come upon the following example of asymmetry in a Bash regex that is confusing me. I would like to know what I am doing which is non-standard and causes this behaviour, or else what is the ...
0
votes
2answers
208 views

XOR in shell globs

Recently my hosting provider changed my public_html directory's name to www without me knowing it so this variable declaration web_application_root="${HOME}/public_html" no longer works. For ...
0
votes
1answer
58 views

how to replace a substring of a line after multiple keywords/patterns have matched

I need to go through thousands of files and find lines that start with # disabledRule: On these lines I need to look for a series of keywords, namely fileinto or fileinto_copy followed by create and ...
1
vote
1answer
72 views

Bash: substitute last occurrence of given pattern in search and replace

The Bash Hackers Wiki says ${PARAMETER/PATTERN/STRING} ${PARAMETER//PATTERN/STRING} This one can substitute (replace) a substring matched by a pattern, on expansion time. The matched substring will ...
0
votes
1answer
43 views

Linux mint 'apt list' doesn't work with packages starting with W

I am pretty new to Linux. I have Linux Mint 19.3 installed. So basically as I understand apt list works with wildcards like * and ?. It works fine with most other letters and letter sequences I had ...
1
vote
1answer
601 views

grep: use square brackets to match specific characters

So I am experimenting with the power of grep using this resources The problem I am currently encountering is that it doesn't seem to work as I intended. so I have an demo.txt file that contains foo....
0
votes
0answers
13 views

How could I make "assets/**/*.webp" work in shell script? [duplicate]

If I use ls -l assets/**/*.webp in bash, it works fine However, if I put it into a script, it will complain: ls: assets/**/*.webp: No such file or directory I noticed that if I remove the trailing ....
1
vote
1answer
18 views

Wildcards in Vim not working as expected – how to remove binary column from example?

I've tried to removed the binary columns in my octal help function. First echo is in line 70, I wanted to delete |000 and the same pattern .. first | + three numerals for all echo lines. So I have ...
1
vote
2answers
87 views

Wildcards: How to exclude a string? (Does not contain) [duplicate]

I was practicing the use of wildcards today .. that was a lot of fun. The most complex thing that worked out exactly as I was expecting was: ls [![:digit:]]*[a-z][0-9][0-9][0-9][aA-zZ]*[![:digit:]] ...
0
votes
1answer
118 views

Makefile with combinations of multiple targets and dependencies

I have the following file tree (for example): foo/1213.csv foo/7789.csv far/8471.csv far/7811.csv boo/8109.csv bar/2778.csv bar/3334.csv bar/1337.csv Now, I want for each foo far boo bar directory ...

1
2 3 4 5
22