Globbing means matching files by name patterns containing wildcards.

learn more… | top users | synonyms (2)

3
votes
2answers
203 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
316 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
663 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 ...
3
votes
1answer
713 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
227 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
482 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
741 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
610 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
150 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 ...
5
votes
1answer
2k 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
666 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
1k 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
83 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 ...
3
votes
3answers
452 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
311 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 ...
4
votes
5answers
782 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 ...
3
votes
2answers
1k 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
204 views

Selecting latest files and grouping by name

I have a directory containing files of the following name structure. <device>.<yyyy-mm-dd-hh-mm-ss> I am working on a script that will retain the the last X copies of these ...
7
votes
1answer
5k views

What is the .gitignore pattern equivalent of the regex (Big|Small)(State|City)-[0-9]*\.csv

I have a regex I stuck in my .gitignore similar to: (Big|Small)(State|City)-[0-9]*\.csv It didn't work so I tested it against RegexLab.NET. I then found the gitignore man page which led me to ...
7
votes
1answer
527 views

Why is bash extended-globbing variable substitution acting at the byte level?

I thought that bash variable substitution and globbing worked at character resolution, so I was rather surprised to see it acting at the byte level. Everything in my locale is en_AU.UTF-8 When ...
4
votes
1answer
811 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? ...
1
vote
1answer
1k 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* ...
21
votes
9answers
33k views

Converting multiple image files from JPEG to PDF format

I want to convert some files from jpeg to pdf. I am using following command. $ convert image1.jpg image1.pdf But I have 100 images. How should I convert all of them to corresponding pdfs? I ...
5
votes
3answers
604 views

Bash globbing of multi-part argument

Below are some examples of a find command I'm trying to run. I'm looking for different ways that I might be able to use globbing to generate (as an example) a find command with predicates joined ...
11
votes
4answers
1k views

How do I choose specific files in a different directory using bash?

I want to list (or delete, or do some other operation) on certain files in a directory, like this: $ ls /opt/somedir/ aa bb cc aa.txt bb.txt cc.txt $ ls /opt/somedir/(aa|bb|cc) ## pseudo-bash ...
7
votes
6answers
7k views

What's the best way to count the number of files in a directory? [duplicate]

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 ...
30
votes
2answers
21k views

How to use wildcards (*) when copying with scp?

Why can't I copy with scp when I'm using * characters in the path? scp SERVERNAME:/DIR/* . What configs do SCP need to allow * in the path? UPDATE: the problem is not on server side, pscp is ...
8
votes
4answers
9k 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.
-2
votes
1answer
268 views

Why does this script show all files in the directory and not just PDF files?

I wrote the script below to find the number of PDF files in a given directory. However, it instead shows all the files in the directory: #!bin/bash message="." message1="*.pdf" ls -al $message ...
6
votes
2answers
1k views

ZSH: Recursive globbing with .directories

I thought the glob pattern: **/(*|.*) would represent every folder and file starting with dot (.) or not, but it skips directories in the current directory that start with .. What is the glob ...
8
votes
4answers
1k views

How to silently get an empty string from a glob pattern with no matches

Say I have a folder with three files: foo1 foo2 bar 1. If I run list_of_files=$(print foo*) echo $list_of_files I get: foo1 foo2 2. If I run list_of_files=$(print bar*) echo $list_of_files ...
1
vote
2answers
231 views

Generate a list of files from a file containing a series of globbing patterns

I am looking for a way to build a list of files by parsing a file that contains a sequence of zsh globbing patterns. The final goal is to pass this list of files to hg add in mercurial. For those ...
2
votes
4answers
986 views

Access the last file (alphabetically) in a directory

I'm trying to open a file with vim from the command line, the file is in a directory filled with automatically generated files that are prepended with a time stamp. Since I don't know the time stamps ...
4
votes
2answers
851 views

mv on a glob pattern does not work without sudo

I am using MySQL database on Ubuntu machine. My MySQL data directory is /var/lib/mysql/ , since I have a database named "db_test" , so, I have a directory named db_test/ under /var/lib/mysql/ . And ...
6
votes
2answers
2k views

Multidigit ranges of files in lexicographical order in zsh

I would like to specify a range of files (in lexicographical order) with two integers (e.g. 2 to 57) in zsh by globbing. For example: "pick the files 2 to 57 in lexicographical order under the path ...
4
votes
3answers
872 views

Delete matching file from every subfolder of current dir

I used this one to copy file in every dir: find -type d -maxdepth 1 -print0 | xargs -0 -n1 cp .htaccess Now i need to do reverse one and delete file with matching name from every sub directory of ...
4
votes
2answers
5k views

How to use 7z to archive all the files and directories (including hidden ones) in a directory?

Because of specifics of my archiving needs I am not comfortable with solid tar.gz archives and use 7z instead. I use the following command to do this: 7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m ...
10
votes
4answers
16k views

How do I recursively delete directories with wildcard?

I am working through SSH on a WD My Book World Edition. Basically I would like to start at a particular directory level, and recursively remove all sub-directories matching .Apple* - how would I go ...
15
votes
1answer
513 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?
4
votes
4answers
5k views

How to exclude numeric directories with rsync?

I know rsync has an --exclude option which I use quite frequently. But how can I specify that it should exclude all "numeric" directories? In the directory listing below I would like to only have it ...
11
votes
6answers
8k views

Show only hidden files (dot files) in ls alias

I'm using the command ls -a | grep '^\.' for showing only the hidden files. I added the line alias hidden='ls -a | grep '^\.'' # show only hidden files to .bash_aliases file but this does not ...
3
votes
1answer
297 views

Copy files in different subdirectories that excludes a string

I'm trying to copy all files of a type in a given directory and subdirectories but excluding files of a different type. find /var/ftp/pub/bs -iname "*foo*.foo" -exec cp {} /var/ftp/pub/bs1 \; ...
5
votes
2answers
1k views

Why doesn't “rm *” work when there are files that begin with a hyphen?

from: http://seclists.org/fulldisclosure/2011/Sep/190 [USER@MACHINE ~] mkdir ejha [USER@MACHINE ~] cd ejha/ [USER@MACHINE ~/ejha] touch ize [USER@MACHINE ~/ejha] touch -- -f -i [USER@MACHINE ...
4
votes
4answers
583 views

Find files without a number

I am trying to write a simple script that will iterate through all drives except sda. Right now I have this for i in $(find /dev/ -name "sd*" ! -name "sda*") do echo $i done However this ...
4
votes
1answer
483 views

ZSH: Globbing the first N files under a path in lexicographic order

I was wondering if there is a way to specify the first N files under a given a directory in zsh. I am interested in solutions for recursive enumeration (i.e. any file recursively below a path is ...
9
votes
1answer
8k 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: ...
3
votes
2answers
1k 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*' ...
7
votes
2answers
1k views

How does a shell (bash, for example) expand wildcard patterns?

Assume that a directory has 100 files starting with the letter 'a'. If I do a grep <some string> a* from the terminal, how will the shell handle this? Will it expand the regular expression, ...
3
votes
2answers
386 views

Splitting a large directory tree by file type

I have a large data directory (20-30Gb) on my Ubuntu 10.10 desktop machine that consists of many raw data files, processed data files, and assorted scripts, tables, figures etc. generated from the ...
4
votes
4answers
1k views

file $(ls /usr/bin/* | grep zip) command gives me errors. What's wrong?

I'm a total noob when it comes to unix/linux commands and I decided to read a book. I've reached a chapter where they try to explain how to pass the output of commands as expansions to the shell. ...