Globbing means matching files by name patterns containing wildcards.

learn more… | top users | synonyms (2)

1
vote
0answers
25 views

Completion with wildcards in directory names in bash

I can do: $ cd sources/ar #[TAB] here would complete word 'ar' to 'art' I can do $ cd */art #[enter] here would bring me to sources/art I can do $ cd */art #[TAB] that would expand */art to ...
2
votes
2answers
54 views

shopt -s extglob not working as expected

I am trying to recursively change file permissions in a wordpress installation affecting everything below the public_html document root folder, excluding certain folders. I have set extglob on with ...
3
votes
1answer
39 views

how to set globstar for noninteractive shells

I would like to execute commands noninteractively on a remote server that use the ** globstar option. However, globstar is not set by default on the remote, and bash doesn't source any files in ...
1
vote
4answers
94 views

/bin/ls: Argument list too long

I am a biology person and running a program named autodock. I have some files from ZINC library in .mol2 format. As per requirement I need to split this files with the csplit command and I received ...
12
votes
1answer
120 views

[[ and case equivalency in bash

Does if [[ "$1" = pattern ]]; then hook fi always behave the same as case "$1" in pattern) hook;; esac or are there any gotchas?
3
votes
2answers
55 views

How to Run a command on all subfolders

If you have a series of sub folders (like from a to z) and want to run a command on each one of them (like dsmmigrate * & ) how do you do that? The manual approach would be, cd a dsmmigrate * &...
0
votes
2answers
75 views

Wildcard not working in quotes

The script is supposed to loop over subdirectories and match all the filenames (FLA.*Image.*file.jpg and FLA.*Image.jpg) in subdirectories and process it. It also create output folder inside the ...
5
votes
3answers
291 views

for loop glob mishaps

I am trying to set up a script that will loop over a set of directories, and do one thing when it finds .jpg files, and another when it finds .nef files. The problem is, if a directory does not have ....
1
vote
1answer
70 views

Why is find not listing matching files when preceded by an asterisk(*)? [duplicate]

On Ubuntu 14.04, 64 bit, I have set /lib/modules/4.2.0-27-generic/kernel/drivers to be my current directory. I intend to search all files having net present as a sub-string. If I search with a regex ...
0
votes
0answers
30 views

Unrar specific files using wildcards

I want to extract only a specific file type using unrar. With unzip command I can extract all archives with a specific extension. unzip "$FileName" *[.txt,.TXT] How can I do the same with unrar? ...
1
vote
0answers
23 views

Ordering of files opened by program

When I open a set of files, usually just by using a glob character to open all the files in a directory or a subset, typically if not always the default is for the files to be opened by alphabetical ...
6
votes
2answers
399 views

Remove all files with a prefix except the one of the largest size

What is the best way to remove all the files in the current directory with some prefix, except the file with this prefix but having the largest size among all the files with this prefix? (In the ...
0
votes
4answers
101 views

Is there a “ls” replacement that can handle wildcards?

I just learned that ls cannot handle wildcards (ls '*' does not work) and therefore the shell does it before ls is invoked. So the behaviour of ls may be considered as logically for people working 20 ...
0
votes
5answers
109 views

how to iterate through files in directory excluding hidden files

Using: for eachfile in /mnt/thara/* Which iterates through hidden files as well. I don't need hidden files.
2
votes
1answer
34 views

Cannot stop bash to expand star (wildcard character) passed to app from shellscript

I have a shell bash script wich should pass the star ["*"] wildcard character to an application without using quotation marks. I am reading since hours and always find to use "set -f" inside the ...
0
votes
1answer
46 views

I accidentally copied part of /* to /some/directory, how should I fix my mistake?

I did something stupid on a remote linux server: my working directory was /some/directory I ran for dir in $(ls | grep "a_pattern"); do mv $d/* ./my_subdirectory; done Now /some/directory/...
1
vote
1answer
46 views

How to pdfjam by Filename Numbering?

My files masi1.jpg masi2.jpg masi3-1.jpg masi4.jpg ... masi10.jpg masi11.jpg ... Command pdfjam *.jpg. Output: random. Expected output: as the list. There is no parameters in man pdfjam, only ...
1
vote
1answer
50 views

tar specific files in several different subdirectories

I have the following folder structure A |-B | |-C | |-1.log | |-2.log |-10.log |-D |-E |-F |-php.log |-H |-php.log I want to collect all the log files and the php file present ...
1
vote
4answers
61 views

How to open or list all files whose names match two patterns in Bash

Suppose that I have a directory with thousands of files; how could I open all files whose names contain the strings "red" and "green"?
5
votes
5answers
336 views

How safe it is to output to <dir> simultaneously with rm <dir>/*

Sometimes I need to remove all the contents of a directory and create new files there. Can I do something like this and expect all new files to remain intact: % rm -rf regression/* & ( sleep 10 ; ...
0
votes
0answers
20 views

getting wrong order of files with ImageMagick and *.png [duplicate]

I am using ImageMagick to concatenate files which I have named 1.png to 50.png. However the files are arranged in the wrong order going 1.png, 11.png, 12.png ... instead of 1.png,2.png ... It must ...
1
vote
2answers
124 views

find: meaning of the \? sign as a value of the name parameter

What is the meaning of the ? sign in the following command? find /foo/path -name \?
0
votes
2answers
31 views

Listing numbered files using wildcard sequence with predefined range

I have a folder of numbered data files. I am trying to incrementally extract a predefined range of files. The range of files that I am looking for is predefined in two variables, ns and ne, which ...
1
vote
1answer
81 views

Why grep on remote system says file or directory not available

I'm trying to run a grep command on remote system to give me the result for May 22. But reply comes /bin/grep: /var/log/Clients_Logs/127.0.0.1/*: No such file or directory But when I specifically ...
1
vote
1answer
84 views

pattern matching without echo

Why are the outputs different? touch a aa bb ccc echo * a aa bb ccc // I understood, * means matches zero or more * aa bb ccc // I'm confused. echo ? a //OK ? a aa bb ccc // confused ...
48
votes
5answers
3k views

Why is the wild card character * so different between commands zip and rm?

I put together a script to do some file operations for me. I am using the wild card operator * to apply functions to all files of a type, but there is one thing I don't get. I can unzip all files in a ...
2
votes
3answers
78 views

Use a wildcard in directory path

I'm trying to write a bash script where part of a directory is a long, unknown string. I know the first part of the directory name. How do I combine the known string and the wildcard in the path? As ...
4
votes
3answers
314 views

Remove files by regular expression

I want to keep files whose names match [0-9A-Z]{1,2}_\d{4}_\w+?\.dat, for example, A1_2001_pm23aD.dat, K_1998_12.dat, and remove the rest. However, the ls and rm commands do not support such regexes. ...
0
votes
1answer
44 views

globbing and wildcards

Are wildcards ever supposed to be expanded for a program that is not the first in the pipeline? Every example uses wildcard for the first program in the pipelilne. For example, the following does ...
2
votes
3answers
40 views

echo all *.tex filenames in a specific directory

I have a directory structure like this: ├── lebenslauf │   ├── lebenslauf.out │   └── lebenslauf.tex ├── thirdPage │   ├── auto │   │   ├── test.el │   │   └── thirdPage.el │   ├── missfont.log │   ├─...
1
vote
2answers
105 views

gunzip multiple files

I have a directory where there are multiple folders, each of folder contains a .gz file. How can I unzip all of them at once? My data looks like this List of folders A B C D In every of them ...
1
vote
2answers
54 views

expand wildcards “inside a command” instead of in the shell

(This is a simplest working example of something in a much messier context.) I have a directory d with files 1.txt 2.txt 3.txt 4.wav. My current directory is somewhere else. ls d reports 1.txt 2.txt ...
1
vote
1answer
32 views

Bash capturing asterisk inside a file [duplicate]

I have a text file which contains an asterisk as the first character in every line, when I try to process the file in a script like this: while read line; do out=$(echo $line | awk '{ print $3 }') ...
2
votes
1answer
69 views

How to delete files with ~?

I have removed all my python code from the home directory, but when I do ls I get: a11.py~ class1.pdf foobar.txt~ n1 pic.py~ When I do ls like this: ls *.py I get: ls: cannot access *.py: No ...
7
votes
1answer
1k views

Why does `grep fil*` fail?

I found echo file|grep fil* fails, but echo abcd|grep abc* succeeds. I don't understand it, can someone explain? Thanks
2
votes
1answer
51 views

alias ? not working in zsh

I was lead to believe that there were no differences between aliases in zsh and bash, however that appears to not be the case. I had an alias that would help me familiarize myself with the command ...
3
votes
2answers
90 views

Why does ls .* show different files than ls ./.*?

Blank file .ignoramus in current directory exists. bojan@localhost:~$ echo $GLOBIGNORE .ignoramus bojan@localhost:~$ ls .* | grep ignor bojan@localhost:~$ ls ./.* | grep ignor ./.ignoramus tools ...
3
votes
1answer
137 views

Is it dangerous to always have extglob on?

If I turn extglob on to do things like shopt -s extglob rm !(*.html|*.txt) # remove everything except html and txt files Is it unwise to keep extglob on after this? Are there any caveats of having ...
5
votes
1answer
66 views

Bash script single-quotes parameter with globbing value

I'm trying to write a code search script, with configurable directories and files that are excluded. The main part of this script is the following line: out=$(grep -TInr$C$W --color=always \ --...
1
vote
6answers
64 views

Is there any reason to double-check the `find -type -f` results with `-f` bash operator?

In this blog I found a bash script ("Snippets" section) which contains following structure to source individual files from .bash_profile: if [ -d ~/.bash_profile.d ]; then for file in $( find ~/....
3
votes
2answers
50 views

Iterating over glob patterns, not the files in them

I would like to perform the same aggregation operations on each of several bunches of files where each bunch is matched by one glob pattern. What I would not like to do is pipe each file name into the ...
0
votes
1answer
39 views

linux - setting order in which files are read or output with utilities (sorting)

I'm having issues with programs reading files in the wrong order, and also outputting in an undesirable order with utilities such as ls. I've tried some of the LC_COLLATE options, but none of them ...
0
votes
3answers
83 views

why “ls *bash*” doesn't show the .bashrc file [duplicate]

I cd to my home directory and typed ls *bash* expecting it will show a list of files contains "bash". However it is not. While, typing ls .bash* works. According to the documentation, * ...
4
votes
1answer
73 views

What is the sort order when using conditional operators?

I wrote a bash script that processes a list of filenames (using glob expansion, as in for f in *) and then outputs a subset of this list to a file. Subsequently I read the content of this file into an ...
0
votes
1answer
13 views

How can I mix variables and wildcards in fish?

I have a value stored in a variable that I want to use as part of a wildcard, like this: set extension (somecommand) cp *$extension ~/filezone But the * prevents the variable from being ...
8
votes
2answers
1k views

Why did mv delete a file with mv id_rsa *.old? [duplicate]

I wanted to backup my ~/.ssh/id_rsa to id_rsa.old, and it looks like it got deleted! How is this possible? :) root@localhost:~/.ssh# ls -l total 16 -rw------- 1 root root 3326 Mar 12 11:22 id_rsa ...
-1
votes
1answer
48 views

wildcard usage for a directory displaying filenames in linux?

so one of the questions i have been working on is to display the contents of a directory files by using its wildcards do display specific contents, in this case aim using ls and the portion that I got ...
4
votes
1answer
46 views

Deduplicating Bash Brace Expansions

Brace expansions can produce multiple instances of file names if there is an overlap in the matches. A simple example: mkdir testdir; cd testdir touch abcd for f in *{b,c}*; do something_to "$f"; ...
1
vote
0answers
21 views

What does echo *? [duplicate]

Recently I was writing a bash-script and added a line: $ echo * and got an output of file names and directory names. What is the context of this list (just out of curiosity)?
0
votes
1answer
31 views

Why doesn't `tar --exclude` take multiple options?

Looking at the man-page for tar it's stated that --exclude=PATTERN will " exclude files, given as a PATTERN ". I'm not sure if PATTERN is explained in more detail somewhere else, but why does the ...