Globbing means matching files by name patterns containing wildcards.

learn more… | top users | synonyms (2)

3
votes
7answers
249 views

“which” with a little “grep”-like solution?

# which mkdir /bin/mkdir # which mkdi # How can I get the path of the e.g.: "mkdir"'s binary without knowing the name of the binary file? (command). So that which "mkdi" would output the ...
3
votes
1answer
789 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 ...
9
votes
1answer
15k views

How can I assign the result of a command to a shell variable?

I want to assign the result of an expression to a variable and concatenate it with a string, then echo it. Here's what I've got: #!/bin/bash cd ~/Desktop; thefile= ls -t -U | grep -m 1 "Screen Shot"; ...
1
vote
1answer
278 views

restricting pushes to selected Mercurial repositories using `ssh` forced commands and `hg-ssh`

The context of this question is the hg-ssh script. It is helpful but not critical to know something about Mercurial. This script sets up a forced command using public keys so the given public key ...
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 ...
4
votes
1answer
186 views

How/why does this globbing expression work?

In one of my bash scripts I needed to obtain the last part of a colon delimited string. For example I needed to grab the numeric 289283 value from the following value: OK: DriveC-ReadBytesPerSec: ...
0
votes
0answers
107 views

How to use find command with wildcard when current directory contains a match? [duplicate]

Possible Duplicate: find not recursive when file at top I'm having some confusion with the find command. If I type: find . -name *.xml or find ./ -name *.xml I receive a list of all ...
5
votes
4answers
4k views

Find a string only in a specific file inside subdirectories

Let's say I need to find the function GetTypes() in all C# source file (.cs) the directories/subdirectories. I used grep -rn GetTypes *.cs, but I got an error with grep: *.cs: No such file or ...
2
votes
6answers
298 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
173 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 ...
5
votes
3answers
323 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
318 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
5k 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
187 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
2k 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
603 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 ...
32
votes
6answers
33k 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
647 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
902 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 ...
25
votes
7answers
23k 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
204 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
5k 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?