Globbing means matching files by name patterns containing wildcards.
9
votes
3answers
325 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
116 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 ...
0
votes
2answers
3k 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
188 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 ...
2
votes
2answers
95 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 ...
4
votes
4answers
243 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
3answers
1k 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 ?
17
votes
1answer
649 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
165 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
205 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 ...
3
votes
3answers
347 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
5answers
930 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 ...
5
votes
2answers
147 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
75 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 ...
12
votes
5answers
3k 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 ...
1
vote
3answers
2k 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
302 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
...
3
votes
2answers
368 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
230 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 ...
11
votes
2answers
217 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 ...
1
vote
1answer
182 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
1k 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 ...
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
3answers
251 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
202 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* ...
14
votes
4answers
3k 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
5answers
337 views
What is the difference between $* and $@?
Consider the following code:
foo () {
echo $*
}
bar () {
echo $@
}
foo 1 2 3 4
bar 1 2 3 4
It outputs:
1 2 3 4
1 2 3 4
I am using Ksh88, but I am interested in other common ...
3
votes
2answers
225 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
221 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 ...
8
votes
3answers
2k 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 ...
5
votes
3answers
336 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
942 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 ...
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 ...
3
votes
2answers
155 views
Finding program name by wildcard pattern
I am trying to write a script that will attempt to find if a certain program is installed. Lets say that the program is called, myprog. The problem is that the program can be named in different ...
2
votes
2answers
207 views
Untar directory from large tarball
How do I untar a directory that I don't know the path to? I only know the directory name.
I know how to untar a single file with a wildcard: tar -xf somefile.tar.gz --wildcards --no-anchored ...
2
votes
3answers
266 views
loop to paste specific files in different directories
I some directories that contain a similarly named file eg (*Sample_name*.base.coverage.txt). And I would like to paste all of the *base.coverage.txt files together. I have something written, but its ...
2
votes
1answer
333 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 ...
4
votes
2answers
168 views
Why 2 linux machine behave differently with command of the same syntax?
I am using 2 machine , which is both Red Hat Enterprise Linux AS release 3 (Taroon Update 2)
( I check it in /etc/*-release ).
I checked they are using the same default shell by ps -p $$, which is ...
2
votes
5answers
236 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 ...
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 ...
3
votes
3answers
291 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 ...
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
...
4
votes
1answer
612 views
The best way to expand glob pattern?
I need to expand a glob pattern (like ../smth*/*, or /etc/cron*/) into a list of files, programmatically. What would be the best way to do it?
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.
1
vote
3answers
473 views
How can we rename a file with semi-colon as part of the filename?
I tried to rename all file with extension "XLS;1" to "XLS" but it just didn't work.
I tried the following in cygwin in windows xp and they don't work:
mv *.XLS;1 *.XLS
mv *.XLS\;1 *.XLS
mv ...
1
vote
1answer
63 views
List all the matched files starting from an index
In zsh, there is the [m,n] glob qualifier which works as follows:
[beg[,end]]
specifies which of the matched filenames should be included in the
returned list. The syntax is the same as for ...
2
votes
3answers
260 views
Where did scp put these files?
I ran an scp command to download some files from an SSH server. Instead of using the . to put it in the current folder, I accidentally typed *. It looks like scp copied the files and put them ...
4
votes
3answers
228 views
How to pipe to multiple places with vertical bar?
I have a folder full of files with a .dot extension like this:
a.dot
b.dot
c.dot
I want to go through all the files in this folder and run a command on them such as this:
dot -Tpdf a.dot -o a.pdf
...
3
votes
5answers
393 views
How do I extract all .htaccess files from a tarball?
I want to extract all .htaccess files from a tarball, how can I do so? I see only one mention of "include" in the manual page of tar which is not related with an option for including only certain ...
2
votes
2answers
255 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 ...