Globbing means matching files by name patterns containing wildcards.

learn more… | top users | synonyms (2)

3
votes
1answer
788 views

shopt -s nocaseglob is not working on Ubuntu

Case insensitive file name globbing is not working in bash on Ubuntu 11.04 64bit. The shell options specified in .bashrc are as follows: shopt -s nocaseglob shopt -s nocasematch shopt also shows ...
3
votes
1answer
58 views

find files without extension

Let say I have: foo.txt bar baz.ooo If I use ls -1 !(*.*) then I'll get only bar on the output. Great, now I wish to have same results with find - some find -regex that will do the job. NOTE: ...
3
votes
1answer
607 views

Bash globbing hidden files

I'm trying the following globs in a bash shell: $ ls -d .* . .. .a .ab $ ls .a* .a .ab $ ls .[!.]* .a .ab $ ls .[!.]?* .ab Shouldn't the last expression mean "a dot followed by exactly one ...
3
votes
3answers
2k views

Get the number of files that match a pattern in a directory and delete the oldest one

I'd like to do the following: Get the number of files in a given directory that match a given pattern, for example: ExtractBackup_{date}.tar.gz If that number is 2 or higher, delete the oldest file ...
3
votes
1answer
43 views

**/ not working with a mounted volume

I'm trying to recursively extract a set of .jpgs from a mounted volume using SMB1, to a folder on my computer. Here's what I've got: cp -a **/97*.jpg /Users/.../All_Covers This works as long as my ...
3
votes
1answer
110 views

watch command to delete files in a directory every N secs

I thought of using watch command to delete files in a directory every N seconds with the command running in background. This is what I was planning to use: nohup watch -n1200 rm -rf ...
3
votes
1answer
106 views

How to use parameter substitution in glob pattern (zsh)

I want to process a bunch of files ending in some suffixes, so I wrote the following zsh script but it did not work. EXT=(.jpg .png .gif) EXT=${(j.|.)EXT} # EXT becomes '.jpg|.png|.gif' for f in ...
3
votes
2answers
688 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 ...
3
votes
3answers
538 views

Configure bash globbing

After coming from cygwin, I'm quite confused about the bash (version 4.1.5) globbing on my Ubuntu 10.4. I'd love one of the following two possibilities: ignore . and .., match everything else ignore ...
3
votes
2answers
954 views

rsync pattern copy: dotfiles

I followed the advice given in the question Rsync filter: copying one pattern only to setup a command line I need to backup only the dotfiles .inF* Yet with the command: rsync -av --include='.inF*' ...
3
votes
2answers
67 views

Error when calling mv with wildcards

#! /bin/bash error_text=$(tail -n +1 /path/dir/folder/exc/a/update/Abd/ER/* | \ grep 'Warning\|Loaded\|Event') echo $error_text nc 10.10.99.45 25 << EOF ehlo mail.abc.pvt mail from: ...
3
votes
1answer
298 views

bash globstar matching

I have this directory structure: ~/tmp/globstar ɀ find dir -type f dir/file.ext dir/subdir1/file.ext dir/subdir2/file.ext and, with the globstar option enabled in Bash, I can say: ~/tmp/globstar ...
3
votes
3answers
1k views

How to delete 2 months back files in unix

Say I have below log files, AA_XX_20130719185428.log exec_xxx_cpb_20130712182453.log 13122013121327_AR_INC_DOBC_1.dprf.log 24122013_masterscript.LOG Date part contains both date and time. I want ...
2
votes
2answers
125 views

Discrepancy between the two expansions

If you input the command ls * and echo *, you will notice the remarkable discrepancy between the results. The former recursively includes while the latter totally excludes files in subdirectories. ...
2
votes
2answers
892 views

Excluding a directory name in a zsh recursive glob

I'm running zsh on Linux under setopt extended_glob ksh_glob glob_dots. I'm looking for something easy to type on the command line, with no portability requirements. I'm looking at a source code tree, ...
2
votes
4answers
10k 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 ?
2
votes
5answers
346 views

Is it possible to reference the most recently modified file in a command line argument?

I frequently download PDF files with heinous numeric file names from my browser. These automatically go into ~/Downloads. Ideally I would like to just be able to open these files with: evince "the ...
2
votes
1answer
152 views

Why is `find -name *.jks` not returning some files? [duplicate]

find . -name *.jks -print 2>/dev/null returns files of extension jks that do not have underscores as part of their name. Much to my surprise, I have just discovered that * does NOT substitute ...
2
votes
2answers
717 views

How do I run a command on multiple files

This is pretty basic, I have a folder with several subfolders of JS files and i want to run Google's Clojure compiler on all of the files in those folders. The command to process a single file is as ...
2
votes
1answer
357 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* ...
2
votes
3answers
1k views

untar a directory of *.tgz files using a wildcard

I've got a directory that looks like $ ls Broad_hapmap3_r2_Affy6_cels_excluded.tgz DINGO.tgz GIGAS.tgz index.html IONIC.tgz passing_cels_sample_map.txt ...
2
votes
3answers
109 views

Filter a list of strings using math

I have a directory with files listed like so: abc201303130110.txt abc201303140511.txt abc201303150112.txt As you can see, the filename contains a datetime stamp. I want to return all files with the ...
2
votes
2answers
496 views

Working of rm/ls with [0-9]

I am learning the shell commands and came across the short tags eg.[0-9],[[:digit:]] etc.. As a proof of concept i tried deleting all the files with the rm command(i know its not a good practise but i ...
2
votes
5answers
257 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 ...
2
votes
2answers
124 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 ...
2
votes
3answers
3k views

Selecting files that start with $LETTER, or a letter later than $LETTER in the alphabet

Suppose a directory contains the following files: afile1 afile2 bfile cfile ffile ffile2 qfile zfile I am looking for an easy way of selecting all the files which start with $LETTER, or start with ...
2
votes
3answers
75 views

Count files in a directory by extension

For the purpose of testing, I'd like count how many images files are inside a directory, separating each image file type by file extension (jpg="yes". This because later it will be useful for another ...
2
votes
2answers
70 views

how to show total files size in a folder by filtering extension without showing each file size

du -hc *zip shows me total size of zip files in a folder, but it shows also every single file size of the folder. I only need total size. Is there way to show the total size of a folder without ...
2
votes
1answer
94 views

Why the order of wildcard results might be different when used from the terminal or from perl?

There's a folder with a bunch of files and a perl scrip that lists them using ls with a wildcard like: #!/usr/bin/perl system("ls -U -1 dir/*"); I noticed that if I run exactly the same command ...
2
votes
2answers
524 views

Bash Wildcard Partial Match Directory

I have this bash script which is trying to find a directory that partially changes on peoples systems. cd "$HOMEDIR/AppData/Local/GitHub/PortableGit"*"/bin" Yet this does not seem to work - it ...
2
votes
1answer
394 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
837 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 ...
2
votes
1answer
78 views

Move extension-less files with mv

I have a folder with images(png, bmp, jpg) and extension-less files. I cant figure out how to move only the extension-less files. They are all random numbered files.
2
votes
1answer
137 views

Curly Brace glob order?

If I have two files (in a folder with similarly numbered files) such as foo.18 foo.19 And I want to use a glob on them, do I do it like so: cp -r /folder1/*.{19,20} /folder2/ or like so? cp -r ...
2
votes
3answers
1k views

ffmpeg -pattern_type glob — not loading files in correct order

I have a dilemma.. I've had a script for a while now that downloads pictures from a webcam every few minutes. The naming convention just does new_image((len(files(dir))+1) + '.jpg') and that's all ...
2
votes
2answers
76 views

“or” in shell glob

I want to ls the files containing the substring "s1r", "s2r", "s3r" or "s19r" in their filenames. I'm almost there! Botched attempts: ls *s[123][9?]r* The above gives me only files including the ...
2
votes
2answers
160 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
2answers
139 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`
2
votes
1answer
485 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: ...
2
votes
2answers
825 views

zsh: excluding files from a pattern

Say I have the following files: |-- bar `-- foo |-- type_A_1 |-- type_A_2 |-- type_B_1 |-- type_B_2 |-- type_B_xx |-- type_B_xx `-- something_else I thought the ...
2
votes
3answers
3k views

How can I loop through lines of a file and find files matching each line?

In a BASH shell, I would like to take the lines of a file (eg pattern.txt) and find the files on my system whose names contain the patterns in each line of my file. So, I have the following for loop ...
2
votes
2answers
155 views

delete directory with special character in filename

I have these tricky directories that I can't figure out how to delete. If I run ls -ld * I get… drwxrwxr-x 7 user1 taskfmri 2048 Jan 22 15:26 857263 drwxrwx--- 4 user2 ...
2
votes
1answer
94 views

SFTP chroot jail/access based on wildcard

I want to give a list of people SFTP access to /webdocs/ABC* where they will read-write access to only directories that match this wildcard. How do I do this? Can I create a chroot jaill or some ...
2
votes
6answers
1k views

How to make tar globbing work with the 'change directory' option

I have the followin directory structure: base/ files/ archives/ scripts/ I want a script to run from scripts/, compress files that match results.*.log in files/ into a gzipped tar archive ...
2
votes
2answers
149 views

Select greatest numbered filename

Simple requirement but can't find anything online which can achieve it. I have a list of dated files as below... filename_20120101.dat filename_20120102.dat filename_20120103.dat I ...
2
votes
1answer
3k 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 ...
2
votes
6answers
297 views

Copy/Move whole folder but with certain extentions

I have a backup copy of my site located in /tmp/backup and want to copy it to /home/mysite/public_html But my aim is to copy only the .php files (with nested folders) and replace. If I don't have ...
2
votes
2answers
38 views

how to filteri by asterisk or similar expression by rsync in zsh

I have a lot of files named like: /var/log/foo/2014-07-06-01.log ... /var/log/foo/2014-07-20-04.log Everyday I have several log files and I want to download specified day's log files: $ rsync ...
2
votes
1answer
36 views

Globbing fails in zsh, but works in bash

I have an alias in bash, that I'm trying to port over to zsh. I thought it may have been the alias itself, but now it seems it's just the globbing. grep -irl --exclude=\*.{log,class,fuegoclass,dat}* ...
2
votes
1answer
45 views

Can I use variables inside {} expansion without `eval`?

Can I use variables inside {} expansion without appealing to eval? If so, how? This doesn't work: $ touch 1.foo 1.bar $ ls 1.{foo,bar} 1.bar 1.foo $ extensions=foo,bar $ ls 1.{$extensions} ls: ...