Globbing means matching files by name patterns containing wildcards.
18
votes
7answers
11k 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 ...
10
votes
1answer
377 views
How do ${0##*/} and ${0%/*} work?
I'm quite confused about the following regular expressions I found in a shell script:
${0##*/}
${0%/*}
How do they work?
14
votes
3answers
13k 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 ...
6
votes
3answers
3k views
How do I reverse a for loop?
How do I properly do a for loop in reverse order?
for f in /var/logs/foo*.log; do
bar "$f"
done
I need a solution that doesn't break for funky characters in the file names.
27
votes
5answers
2k 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 ...
7
votes
6answers
4k views
What's the best way to count the number of files in a directory?
If parsing the output of ls is dangerous because it can break on some funky characters (spaces, \n, ... ), what's the best way to know the number of files in a directory?
I usualy rely on find to ...
7
votes
1answer
3k views
How to download specific files from some url path with wget
If I don't want to have to download the files found in a specific url path manually, what options do I have? Using wildcards fail:
$ wget 'http://www.shinken-monitoring.org/pub/debian/*deb'
Warning: ...
6
votes
1answer
249 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 ...
5
votes
3answers
264 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 ...
3
votes
1answer
367 views
How do I filter a glob in zsh
Basically I can use a glob in zsh to a list. Often, it turns out, I would like to filter that list, grep'ishly I'm wondering though, if I need to do that.
Does zsh have a method to filter a list? ...
2
votes
2answers
92 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
2answers
227 views
How do I output a count of all files with “tty” in the filename in the Linux directory that holds files on system devices
I am having trouble knowing how to output a count of all files with “tty” in the filename in the Linux directory that holds files on system devices.
17
votes
2answers
791 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 .??* ...
3
votes
2answers
262 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 ...
1
vote
2answers
3k 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?
4
votes
1answer
128 views
What is the tool that allows me to specify arbitrary directories using **
I once saw a colleague uses a tool which allows to use ** to represent any directories. For example: if a file called myfile.java sits deep inside:
src/main/com/mycompany/product/store/myfile.java
...
3
votes
3answers
162 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
324 views
Is it possible to change the order of a glob?
I am trying to show all instances of a particular message from the syslog in chronological order by doing something like the following:
grep squiggle /var/log/messages*
Unfortunately the glob ...
1
vote
1answer
488 views
Difficulty making a regular expression to find at least 2 occurrences of a character in a file
I have a file containing random codes. Each code has ten characters in it, and I am trying to grep codes in the file that have at least 2 occurrences of a character. I am doing this:
grep DD* ...
