Questions tagged [wildcards]

Globbing means matching files by name patterns containing wildcards.

Filter by
Sorted by
Tagged with
-1
votes
0answers
21 views

What type of pattern can I use with pgrep/pkill?

Looking at the manual page, the pgrep and pkill commands are defined as: pgrep [options] pattern pkill [options] pattern Now I'd like to kill (SIGTERM or SIGINT) a node process. The trick is that I'...
2
votes
1answer
39 views

Search directories containing numbers larger than a certain threshold in their name

This is the command that I have and would like to modify with an additional condition: find /home/user/backups/ -mindepth 2 -maxdepth 3 -name "*~EEEE000.tif" -print This is the output of ls /home/...
0
votes
1answer
42 views

Grep different kinds of patterns

I have a file that looks like this: 1>>>PROKKA_00001 Transcriptional regulator PadR-like family protein - 137 aa >>tr|E5G076|E5G076_ARAHY Ara h 1 allergen OS=Arachis hyp (619 aa) 37.3%...
2
votes
2answers
108 views

Script to recursively replace invalid characters in filenames, not directories, with rename

I'm looking to write a script that will find and replace any characters other than [^A-Za-z0-9._-] in a specific file type (in this case .avi) with an underscore _. I want this to exec recursively ...
3
votes
3answers
734 views

new decade: how to utter something like `find /path/ -name 'file.20{19,20}*'` (but which works)

summary: A given system has lots text files with names ~= [type of file].[8-digit date]. To search these files, I like (and wanna keep) using this idiom: find /path/ -name 'file.nnnn*' -print | xargs ...
0
votes
3answers
81 views

Can echo be combined to produce a single result of .*/ and */?

The echo command outputs differing results based on the expression passed to it. The working directory is /home/etc $ echo .*/ / ../ .cache/ .config/ .gnupg/ .local/ .mozilla/ .ssh/ $ echo ./* ./...
0
votes
0answers
18 views

How to establish an ip tunnel to multiple addresses?

I want to establish a tunnel (ip4ip6) to multiple IPv6 addresses. I'm trying to do something like this: ip tunnel add sometunnelname mode ip4ip6 local 2001:db8:abab:fefe::1 remote 2001:db8:abab:fefe::/...
-1
votes
2answers
41 views

How to print text between 2 patterns with wildcards?

I need to capture the text between two patterns, but those patterns may contain numbers that change. Also I only care about lines with this structure that begin with that letter sequence, any other ...
1
vote
4answers
118 views

Bash - print reversed file list using glob

Is there a way to reverse a file list via glob? So I would get the same result as with: ls -r * I'm using this in a shell-script and shellcheck keeps complaining: ^--------^ SC2045: Iterating ...
1
vote
1answer
85 views

cp and mv using wildcards and forgetting to specify a destination directory [closed]

It has happened to me several times that I used cp or mv with wildcards but I forgot to specify a destination directory. Here is an example of the mistake when collecting logs: ~# mkdir problem_logs ~...
-1
votes
1answer
111 views

Data searching (matching) mechanisms standard in generally all Linux systems [duplicate]

I feel confused about what data searching (data matching) mechanisms are standard in generally all Linux systems, as being utilizable by generally all shell builtins and additional common utilities, ...
10
votes
4answers
633 views

Bash globbing that matches all files except those with a specific extension, that works on filenames that include dot characters

I'm doing some stuff with audio files, most but not all of which are mp3 files. Now I want to run some commands on only the files which are not mp3 files, or only those which don't have a .mp3 ...
0
votes
1answer
27 views

Writing a glob-match testing function

In a higher-level programming language I am working on writing a wildcardMatch(input, pattern) function that I want to work exactly like the glob matching in Unix. To do this I have been using ...
2
votes
2answers
45 views

How to process all files in a folder with python code

I have the following code in python: #/usr/bin/python from Bio import SeqIO count = SeqIO.convert(“genome1.gbk”, “genbank”, “genome1.fasta”, “fasta”) print("Converted %i records" % count) This ...
0
votes
1answer
16 views

bash script for checking to see .AWK extension

if [ ! $var = " *.awk " ] ; then echo "$var contains awk file" fi this is what I have but when I run it and put a file name without .awk it still says contains awk file
2
votes
2answers
392 views

Pattern matching in a zsh conditional expression

I am having trouble with pattern matching in zsh's hook function precmd. I have the following: precmd(){ local x='test' if [ $x = '*test*' ]; then echo 'hello' fi } which does not ...
0
votes
1answer
42 views

How to display different directory content with Bash select command?

So far I have found some examples of Bash select function usage with logical constructed options or Asterisk one (i.e select s in *). This last one lists all actual directory content. So I would like ...
0
votes
0answers
32 views

What is a proper way to securely use legacy visudo sudoers?

I wanted to run a script as another non-login user like this: /srv/system/check_alerts.sh <NAME> with 1 argument of only uppercase letters and Variable Lengh. Because Visudo is ...
0
votes
1answer
52 views

piping ls to other programs vs loop globbing [duplicate]

I am reading about the pitfalls of parsing ls and the examples given are about looping ls with for/while. The article title says 'parsing ls' - does that mean piping the output of ls to awk and other ...
3
votes
2answers
82 views

Limiting the scope of glob qualifiers in zsh

I'm almost certain that this is not something that the zsh shell provides a way of doing, but I thought I'd ask anyway just to make sure I'm not missing anything from the manual. With the zsh shell, ...
0
votes
2answers
40 views

Bash glob expanding to multiple arguments

I am new to bash scripting. I've got a script to ping multiple machines that "I" wrote : for var in "$@" do ping -c 1 -W 2 "$var" > /dev/null echo $var = $? done What I'd like to ...
4
votes
1answer
85 views

Returning randomised items from glob match

With the glob qualifiers in zsh one can sort the results of a filename globbing pattern match in various ways. For example, the pattern *(om) would match all non-hidden names in the current directory,...
0
votes
1answer
78 views

Bash * directory wildcard not working in if statement using double brackets

This works: if [ /a/*/b/file.asd -nt /c/d/file.asd ]; then echo "found new file"; fi This doesn't work: if [[ /a/*/b/file.asd -nt /c/d/file.asd ]]; then echo "found new file"; fi Can someone ...
0
votes
1answer
31 views

Using paths from a function that uses globbing

It is known that parsing the output of ls is generally a bad idea and one solution is to use globbing instead of ls to 'safely' loop through files in a directory. for path in /path/to/search/*; do ...
0
votes
1answer
142 views

what is GREEDYDATA in elasticsearch

reading the conf files of logstash i found in filter conf grok { match => { "message" => "Put\s*command\s*:\s+%{GREEDYDATA:command}" } } How does this filter work , i tried to ...
8
votes
1answer
88 views

bash extglob: Should the order of patterns in a pattern list matter?

According to the bash manual, if extglob is enabled, the pattern @(pattern-list) should match any of the patterns in pattern-list (separated by |). Here it works as expected: $ shopt -s extglob $ ls -...
33
votes
4answers
4k views

Why would the command “ls *” generate an error about invalid options?

There is a thread that talks about ls "*" not showing any files, but I actually wonder why the simple ls * command doesn't output anything in my terminal other than ls: invalid option -- '|' Try '...
0
votes
1answer
26 views

Bash extglob pattern with comma

Suppose extglob is turned on in Bash (I use 5.0.11(1)-release (x86_64-apple-darwin18.6.0)) and we have a file with the name list89988777,,,,,+--.txt. I cannot get a , to work in extglob pattern with [....
4
votes
1answer
99 views

Why is this (extended) wildcard matching a filename that I'm trying to exclude?

Why is 'myscript.txt' displayed when I run the command $ ls !(my)*.txt myscript.txt hey.txt and on the same note, how is bash interpreting $ ls !(my)*.txt and $ ls !(my*).txt?
0
votes
1answer
35 views

Wildcard in Makefile doesn't do anything

I'm trying to compile a kernel module named DAHDI in a FreePBX (RHEL). I get the following make output error: You do not appear to have the sources for the 3.10.0-957.21.3.el7.x86_64 kernel installed....
0
votes
2answers
25 views

Iterating over files and preforming operations on them

I am relatively new to unix and linux bash scripting and have a few questions: First here is my script: for fileref in Ref/*.bed; do for filename in Data/*.bed; do bedops -e 1 $...
0
votes
2answers
99 views

Bash: Globbing and file conditions [duplicate]

I am trying to check wether a file exists or not: This works as expected: if [ -e "/tmp/test.*.lock" ]; then echo "exists!" fi This does not: if [[ -e /tmp/test.*.lock ]]; then echo "exists!" ...
2
votes
1answer
41 views

zsh completion tag-order matching patterns

Is it possible to use matching patterns instead of ignored-patters in tag-order? I'd like to try a custom limited set of matching completions on the first try without a prefix, like this: $ man <...
2
votes
1answer
30 views

Cycle with exception in bash [duplicate]

How to write a cycle pro all files *.py except a.py? for i in *.py && !(a.py); do python3 $i done
0
votes
1answer
33 views

Globbing and find command. Difference between encapsulating globbing in “ ” and not [duplicate]

Why does find . -name "*.jav" work while find . -name *.jav does not work if there are more than 1 .jav files? What do the " " do and why is the "*.jav" not interpreted as a literal string?
0
votes
2answers
29 views

extglob behavior, particularly when using *(patternList) in bash

I am trying to use extglob, however, after the man pages I'm confused about how *(patternList) operates. Assume I use the following commands: touch A Ax Axxx Axxxx Ay X X.bak x xx xxxx ls ...
0
votes
1answer
126 views

zsh ignore glob if nomatch [duplicate]

To list all docker repositories I need to use an asterisk. But I am forced to add quotes because zsh globbing catches the asterisk. sudo docker image list "hub.local/*" I try aliasing with noglob, ...
1
vote
1answer
44 views

Wildcard does not work with rename when renaming filenames in folder

I have a series of files in a folder with a string in the middle of the filenames starting with _S (_S1, S2, S143 ....), which I need to get rid of/replace with just and underscore. Like this ...
2
votes
1answer
99 views

Globbing with negation in ZSH

I’m trying to get something like ls **/*!(test).rb to expand to all ruby files which do not end with “test”. However, everything I tried so far didn’t help. I tried turning on ZSH’s expanded globbing ...
0
votes
1answer
179 views

Zsh string pattern match to delete spaces

Trying to solve a code-golf problem using zsh, but my regex isn't working correctly. Requirement Given input string $1, delete all spaces immediately to the left of any ! character. Examples: ...
1
vote
1answer
152 views

UNIX/SED - Wildcard in file name

File name is: file_201909091143.csv How to add a wildcard to pull all files that start with 'file' ? #!/bin/bash #cleans blank rows sed -i '/^$/d' file?.csv #wildcard missing UPDATE directory's ls: ...
-2
votes
2answers
52 views

find and copy usage using wildcards

I'm looking to copy a specific folder inside an other one, but I don't have the exact names, for example /volume1/User/save/01/**-**** ?/GROUPES **-****/ **-**** is a number reference that changes ...
-3
votes
1answer
54 views

How do I convert [*] into a regular expression? [closed]

Essentially I need to Ctrl+f (search for) the following string... [*] This means that I want to find everything that matches between (and including) the brackets. What do I substitute the "*" for ...
3
votes
3answers
372 views

Exact number of same characters in word-grep

My task is to find lines with egrep in which first word contains exactly three same letters. I've tried to use backreferences but only found a way to build pattern which finds words builded from 3 or ...
0
votes
1answer
57 views

How to enable “extended_glob” in tcsh?

I am looking to enable 'extended_glob' in tcsh shell and I tried these commands: setopt extended_glob shopt extended_glob But , None of these worked. Can anyone let me know a way to enable this in ...
1
vote
1answer
60 views

Paste & Brace Expansion vs Wildcard

Why does a brace expansion behave differently than wildcard in combination with paste? Example: Assume we have multiple folders, each containing the same-structured tsv and want to create a 'all.tsv' ...
0
votes
0answers
97 views

grep -f not working with file

I have a file with having patterns separated by new line characters. which matches the patterns i want to find from a file. but when i run command grep -f patterns_file words_file It gives no ...
2
votes
2answers
330 views

Wildcards not interpreted by shell script when used with output redirection

Say I have two scripts: script1.sh: #!/bin/bash version=2.6 log_file="$HOME/log-file-version-$version.log" touch $log_file &>/dev/null echo "log to my log file from script 1" >> $HOME/...
2
votes
1answer
120 views

Why doesn't zsh like a file glob like *17*?

I am a relatively new zsh user, and love it 99% of the time. When I try to copy a bunch of files, eg: [I] ➜ ls *17* core.txt.17 info.17 vmcore.17.zst but when I scp *17* xxx:xxx/xxx, I get: ...
4
votes
0answers
112 views

dash not expanding glob wildcards in chroot

I'm working with a copy of Raspbian, installed with pi-gen. Pi-gen runs in a Docker container with a volume for the filesystem, running debootstrap and custom scripts inside a chroot to the volume. I'...

1 2 3 4 5 19