Globbing means matching files by name patterns containing wildcards.

learn more… | top users | synonyms (2)

4
votes
2answers
553 views

Get the complement of the result of an ls command

Let's say I have a directory with multiple files, all of which are either binary files (files with no declared extensions) and source files (.c extension). I do this: $ ls and get: README.md ...
3
votes
5answers
233 views

Regex match in CLI

Is there something like a logical for the cli? I want to achieve this mv -t newfolder *.(png|jpg) so that alls jpg and png files are moved into newfolder. I know it could be done with mv -t ...
2
votes
2answers
97 views

Select a range of logs from daily log archives

I have a folder containing daily logs, named as : system-2013-01-01.log system-2013-01-02.log system-2013-01-03.log system-2013-01-04.log system-2013-01-05.log system-2013-01-06.log ...
3
votes
1answer
4k views

rsync all directories that start with a specific digit

I have directory loaded with thousands of sub directories: /home/tmp/ 1 12 123 1234 2345 234 3456 345 34 ...
10
votes
5answers
2k views

Pattern matching on path names in bash

I want to act on a list of subdirectories in a directory. Consider: for x in x86-headers/*/C/populate.sh; do echo $x; done This gives x86-headers/elf/C/populate.sh x86-headers/gl/C/populate.sh ...
3
votes
1answer
164 views

Passing all files of specific filetype in current and subdirectories

I have constructed an elaborate 500+ character command with many arguments and switches to autosign multiple PDF documents. I'm using JSignPDF and I'd like to use it's batch mode including the ...
2
votes
2answers
164 views

Bash variables and types

I'm making a script that validate an IP address. I do this: read pool checkIp() { local ip=$1 local stat=1 if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then ...
2
votes
5answers
333 views

Copy Sequential Files

I have 12 files named dmp_000, dmp_001, etc, all the way to dmp_011. I would like to copy all of them to rdmp_000, rdmp_001, and so on, sequentially so the numbered files coincide. There must be an ...
1
vote
2answers
528 views

aptitude remove pkg_name* not working like apt-get

I have uninstalled (aptitude purge) the qt-sdk package but there is still a lot of qt4* and libqt* packages on my system. Is there a way to remove all these packages with aptitude remove/purge ...
37
votes
6answers
6k views

The result of ls * , ls ** and ls ***

I know using the command ls will list all the directories. But what does the ls * command do ? I used it and it just lists the directories. Is the star in front of ls means how deep it can list the ...
2
votes
2answers
153 views

What is an equivalent of rm `find lib/ -name *.swp` without find?

As in the title, I would like to remove all files in the lib directory with .swp in the end. How can I do this without find in: rm `find lib/ -name *.swp`
7
votes
1answer
430 views

What is the significance of the dot in bash commands and how is it different from an asterisk?

I'm trying to understand the significance of the dot in bash and how it differs from an asterisk. Can someone please elaborate? For example, what's the difference between cp -ar /foo/. /foo2/ and cp ...
9
votes
7answers
6k views

How do I create a directory in all subdirectories?

Suppose I have a directory structure like this: $ [~/practice] ls a/ b/ c/ d/ Now I want to create a directory tmp1 in all sub directories of practice and I do this: $ [~/practice] mkdir */tmp1 ...
9
votes
2answers
848 views

“grep -r foo *” vs “grep -r foo .”

When using grep -r you could search in all files with either * or . and it seems to return the same thing but is it really the same? Let's say I search for "foo", then I could write grep -r foo * ...
9
votes
3answers
2k views

what is wild card to select all directories in a directory

i want to set sticky bit for all directories in a directory excluding files. is there any wild card to do this? #sudo chmod g+s /var/www/<WILD_CARD_FOR_ALL_DIRECTORIES>
1
vote
1answer
327 views

imagemagick globbing multiple extensions

I have a folder containing photos coming from different cameras. I use Imagemagick to convert to resized and renamed photos in another folder. Something like this: convert "*.jpg" \ -resize 640 ...
6
votes
2answers
40k views

Zip all files in directory?

Is there a way to zip all files in a given directory with the zip command? I've heard of using *.*, but I want it to work for extensionless files, too.
0
votes
4answers
610 views

Bash Globbing Variable Substitution? [duplicate]

Possible Duplicate: Batch renaming files I want to rename files using their existing name as a base for the new one. So if I can ls these files with ls blue*+(.png) I'd want to rename ...
15
votes
3answers
768 views

What is the difference between [[ $a == z* ]] and [ $a == z* ]?

Is there is any difference between these two. [[ $a == z* ]] and [ $a == z* ] Can I have an example where they would have different outputs? Furthermore, how does the working of [[ ]] differs ...
2
votes
2answers
138 views

Zipping files two by two

I have a directory that has 800 files like this: file1.png file1@2x.png file2.png file2@2x.png file3.png file3@2x.png ... etc I need to create zip files like this file1.zip (containing ...
8
votes
4answers
898 views

Avoiding errors due to unexpanded asterisk

In bash I often use for-loops such as the following for file in *.type; do sommecommand "$file"; done; to perform an operation for all files matching *.type. If no file with this ending is ...
2
votes
4answers
13k views

Unix Command to return all files that end with single digit and TXT extension

Which command returns all files that end with a single digit and have the TXT extension ?
19
votes
1answer
741 views

Why doesn't 'find' show this file?

Using find with grep, one can locate files that match a pattern: # find | grep error ./solr-modifiedSolr4/SolrPhpClient/phpdocs/errors.html ./error_log ./includes/classes/error_log However, using ...
2
votes
1answer
590 views

unzip two different kind of file extensions

Note here, .zip and .jar is just an example, my file extensions are different. Suppose I have a directory which can contain number of zip files a.zip b.zip c.zip AND/OR z.jar x.jar y.jar along ...
2
votes
2answers
1k views

Using wildcards to match a directory in bash

Lets say the folder structure is like so: /home/ --user1/asdf --user2/asdf1234 --user3/asdf325234 --cool/asdf How could I change to asdf1234 without specifying the user? For example: cd ...
1
vote
1answer
143 views

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/ ...
4
votes
3answers
3k views

Using OR patterns in shell wildcards

Contents of my dir are $ ls -lrt total 0 -rw-r--r-- 1 user1 admin 19 Oct 8 12:31 night.txt -rw-r--r-- 1 user1 admin 19 Oct 8 12:31 noon.txt -rw-r--r-- 1 user1 admin 38 Oct 8 12:31 day.txt I ...
1
vote
6answers
5k views

ls: Do not show directories that match same pattern in wildcard searches, only files

Supposing I have something like the following, a typical business PC situation: drwxr-xr-x 1 whatever whoever 3 Oct 3 16:40 invoices2009 drwxr-xr-x 1 whatever whoever 4 Oct 3 16:40 ...
12
votes
2answers
4k views

Recursive glob?

I'd like to write something like this: $ ls **.py in order to get all .py filenames, recursively walking a directory hierarchy. Even if there are .py files to find, the shell (bash) gives this ...
5
votes
2answers
932 views

How to put the specific files from a directory in an array in bash?

Suppose I have a directory under which there are 3 files named: file1.txt,file2.txt and file3.txt. Now how can I fill an array with those file names(I just know that all the files have certain ...
0
votes
2answers
130 views

HTTP Downloader that supports directory index? So that I could use globbing?

Is there an http downloader that supports globbing? i.e. I would like to fetch the latest update of a package, abc-XXX.rpm, but the XXX (version number) is unknown to me. Is it possible to do a ...
0
votes
1answer
902 views

Asking ls to only list files in a path that match a specific glob/regex

In Zsh: Is there a way to use ls to only list files and folders in the current directory that match a specific globbing or regex pattern? For example, say I have multiple files that start with the ...
16
votes
6answers
17k views

How to match case insensitive patterns with ls?

I would like to list all files matching a certain pattern while ignoring the case. For example, I run the following commands: ls *abc* I need to see all the file that have "abc" as a part of the ...
8
votes
7answers
22k views

List only regular files (but not directories) in current directory

I can use ls -ld */ to list all the directory entries in the current directory. Is there a similarly easy way to just list all the regular files in the current directory? I know I can use find find . ...
4
votes
3answers
753 views

How can I list all *.doc files in a Zip archive, including files in subdirectories?

I have Zip files, that might look like this: $ zipinfo -1 zip.zip doc.doc dotx.dotx xls.xls ppt.ppt txt.txt c.c subdir/subdir2/doc.doc subdir/xls.xls subdir/ppt.ppt subdir/c.c subdir/txt.txt ...
4
votes
2answers
7k views

How can I search a wild card name in all subfolders?

How can I search a wild card name in all subfolders? What would be the equivalent of DOS command: dir *pattern* /s in *nix?
3
votes
3answers
622 views

Fastest way to open all files in a directory with multiple file extensions on commandline

If I want to open all mp4 files in a directory, I can simply do something like totem *.mp4. But how can I open all mp4 and all flv files in that directory with one command. I.e. I want to do something ...
13
votes
2answers
381 views

Can I make `rm` interactive only when using globbing? (in either bash or zsh or both)

Whenever I rm multiple items at once with shell globbing and there's even the slightest possibility that the pattern expands to more than I expect it to, I always try to remember to add -i, but (of ...
2
votes
1answer
635 views

Extended file globbing not working with cat inside bash script

When, in my terminal, I type cat ~/my/+(a|b)/doc It reads ok from both ~/my/a/doc and ~/my/b/doc, but when I put that command in a bash script: #!/bin/bash cat ~/my/'+(a|b)'/doc I get the error: ...
5
votes
1answer
6k views

Listing with `ls` and regular expression

How can I list files with a filename ending with last character and with .txt extension ? I have tried ls *+([[:digit:]]).txt but this is true for abc12.txt and abc2.txt. But I need to get only ...
18
votes
2answers
905 views

What does .??* mean in a shell command?

The following command will tar all "dot" files and folders: tar -zcvf dotfiles.tar.gz .??* I am familiar with regular expressions, but I don't understand how to interpret .??*. I executed ls .??* ...
6
votes
3answers
544 views

Get a list of 3 letter commands on Mac OS X

How can I either create or find a list of 3-letter unix commands on Mac OS X? I'd like to create a new program/command for a project. I'd like to make it a 3-letter name, but I don't want to conflict ...
2
votes
1answer
401 views

remote execution via ssh doesn't follow links?

ssh server ls /var/lib/edumate/backup/weekly/*DBB* returns one file /var/lib/edumate/backup/weekly/DBB.0.db2inst1.NODE0000.CATN0000.20120610020013.001 but ssh server ls /data/backup/weekly/*DBB* ...
18
votes
4answers
16k views

How to copy some, but not all files?

So, you can use the * as a wild card for all files when using cp within context of a directory. Is there a way to copy all files except x file?
5
votes
2answers
567 views

How can I make bash not match `.` and `..` with `.*`

When I try to match all dot files in a directory with .* it seems to have a nasty side-effect: besides matching all (real) files and directories, it matches . and ... bash-3.2$ mv test/.* dest/ mv: ...
6
votes
2answers
428 views

What is the setting in bash for globbing, to control whether * matches dot files

I was surprised recently when I did something like mv ./* ../somedirectory and found that files like .gitignore were not moved. I do most of my work in zsh on OS X, and this surprise bit me in bash ...
12
votes
3answers
7k views

How can I remove all symbolic links with a special target?

With the command: ls -la * I can list all my symbolic links. How can I remove all symbolic links which are linked to a special folder? For example: In my directory usr/local/bin I have the ...
6
votes
3answers
1k views

Glob with Numerical Order

I have this list of pdf files in a directory: c0.pdf c12.pdf c15.pdf c18.pdf c20.pdf c4.pdf c7.pdf c10.pdf c13.pdf c16.pdf c19.pdf c2.pdf c5.pdf c8.pdf c11.pdf c14.pdf c17.pdf c1.pdf ...
4
votes
3answers
3k views

Why does tar --exclude=“.*” create an empty archive?

Everything I read says that to exclude .svn and .htaccess and other hidden files when creating a tar archive, use the --exclude=".*" pattern. When I try, I get an empty archive. When I leave out the ...
5
votes
2answers
845 views

How to enable tab completion of wildcards in bash?

How can I enable tab completion in bash for a statement such as vim db/migrate/*crea? Essentially I am looking for tab completion to match the regular expression and present the options. How would ...