Globbing means matching files by name patterns containing wildcards.

learn more… | top users | synonyms (2)

2
votes
6answers
338 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 ...
3
votes
2answers
181 views

returning strings corresponding to shell glob matching

Suppose I have a subdirectory called sub. Then I want to operate on all files in that directory with the extension "txt". I want something like for f in sub/*.txt do enscript -b "" -o {$f ...
6
votes
3answers
359 views

“mkdir foo; svn mv * foo”

I often want to do some variant of this idiom: $ mkdir 2010 $ svn mv * 2010 Of course, I get an error because the glob matches 2010 as well: svn: Cannot copy path '2010' into its own child ...
6
votes
5answers
4k views

How to copy all html files from a directory tree to a single directory?

I want to copy all the .html files in myDir and its subdirectories to ~/otherDir. Here's what I tried (it doesn't work): $ find myDir -name *.html -print | xargs -0 cp ~/otherDir usage: cp [-R [-H | ...
6
votes
1answer
329 views

Can I have my shell history record how wildcards expanded?

If I run: $ ls * foo bar buzz $ history | tail -1 ls * You can see that in my shell history it remembers that I ran ls * rather than ls foo bar buzz. Ideally, I'd like to record both in separate ...
4
votes
3answers
6k views

checking an argument to a bash script is a string of all digits

The Bash FAQ says If you're validating a simple "string of digits", you can do it with a glob: # Bash if [[ $foo = *[!0-9]* ]]; then echo "'$foo' has a non-digit somewhere in it" else echo ...
1
vote
2answers
202 views

Listing all my files modified more than X days ago, in long format

How can I list in long format all files (located in a directory) which belong to me (rights) and were modified more than 7 days ago?
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
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 ...
11
votes
8answers
3k views

How do I delete everything in a directory?

I'm sorry for asking such a basic question: How do I delete everything in a directory, including hidden files and directories? Right now, I use the following: rm -rf * rm -rf .*
5
votes
2answers
652 views

ls, regexp and environment variable

I wanted to declare an environment variable that stocks all the extensions of video files so I can use it when using the shell. I tried several things but never got it to work: If in my .bash_profile ...
41
votes
6answers
38k views

How do you move all files (including hidden) in a directory to another?

How do I move all files in a directory (including the hidden ones) to another directory? For example, if I have a folder "Foo" with the files ".hidden" and "notHidden" inside, how do I move both ...
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 ...
3
votes
1answer
702 views

scp, globbing, and different shells

The other day at work I tried doing scp remotehost:~/*.txt . and I received an error about the *, *.txt file not found sorry, not at work and I forget the exact error on my workstation I run zsh ...
4
votes
2answers
1k views

How can I search for a file with fixed name length using ls?

In a directory, I have files like lazer_100506 lazer_100707 lazer_091211 lazer_110103 lazer_100406_temp lazer_100622#delete etc How can I get a listing of only the first four files? $ ls ...
29
votes
7answers
28k views

Rsync filter: copying one pattern only

I am trying to create a directory that will house all and only my PDFs compiled from LaTeX. I like keeping each project in a separate folder, all housed in a big folder called LaTeX. So I tried ...
5
votes
4answers
210 views

is the behaviour of .* to include . and .. defined in LSB or POSIX or some other specification?

as title: is the behaviour of .* to include . and .. defined in LSB or POSIX or some other specification?
1
vote
2answers
6k views

Delete files in a directory that match a regexp, using a Mac terminal

How do I delete files in a directory that match a given regexp, or a similar solution, using a Mac terminal?