Globbing means matching files by name patterns containing wildcards.

learn more… | top users | synonyms (2)

3
votes
3answers
91 views

Full path in glob in Zsh

Say I run the following on /some/path: for x in foo/*; do print $x done Are there any parameters I can use to tell Zsh to print, not just the filename, but the full absolute path to $x? (without ...
1
vote
2answers
66 views

Is there an equivalent to bash's “nocaseglob” in ksh?

I would like to do what is mentioned in How to match case insensitive patterns with ls? except for ksh. Is it possible to do it without any pain(regex)?
2
votes
2answers
310 views

Bash's declare -p HISTIGNORE brings bash to a halt! Why?

Executing the following code in GNU bash, Version 4.2.45(1)-release (x86_64-redhat-linux-gnu), Fedora 19 ... shopt -s extglob export ...
2
votes
1answer
94 views

Does * match hidden files in tar even with dotglob unset?

I was under the impression that the * glob does not match dot-prefixed files unless you manually enable such functionality (through dotglob, or your shell's equivalent). Yet if I have a directory a ...
3
votes
1answer
49 views

**/ not working with a mounted volume

I'm trying to recursively extract a set of .jpgs from a mounted volume using SMB1, to a folder on my computer. Here's what I've got: cp -a **/97*.jpg /Users/.../All_Covers This works as long as my ...
12
votes
2answers
751 views

Shell filename pattern that expands to dot files but not to `..`?

Recently I had a little mishap caused by a shell pattern that expanded in an unexpected way. I wanted to change the owner of a bunch of dot files in the /root directory, so I did chown -R root .* ...
1
vote
2answers
1k views

Differing outputs of the commands “ls .*” and “ls *.”

The command ls .* when run gives as output the following : All the files in the current directory starting with a . (hidden files) All the files in the hidden directories present in the ...
3
votes
3answers
2k views

How to delete 2 months back files in unix

Say I have below log files, AA_XX_20130719185428.log exec_xxx_cpb_20130712182453.log 13122013121327_AR_INC_DOBC_1.dprf.log 24122013_masterscript.LOG Date part contains both date and time. I want ...
2
votes
1answer
140 views

SFTP chroot jail/access based on wildcard

I want to give a list of people SFTP access to /webdocs/ABC* where they will read-write access to only directories that match this wildcard. How do I do this? Can I create a chroot jaill or some ...
6
votes
2answers
649 views

How does GLOBIGNORE work?

According to bash's manual page: GLOBIGNORE A colon-separated list of patterns defining the set of filenames to be ignored by pathname expansion. If a filename matched by a ...
5
votes
5answers
891 views

How to search in specific files matching a pattern

How can I find a word in specific files matching a pattern. e.g. searching for version in CMake* files recursively found in the current directory.
6
votes
3answers
679 views

ImageMagick on multiple files

I have converted a single file from BMP to PNG with ImageMagick's convert using the command below convert CD\ Front.bmp CD\ Front.png I have many such files, thus I tried: for f in */*.bmp ; do ...
3
votes
3answers
795 views

How to move the first x files

I have this huge folder with thousands of unordered files. Is it feasible to move the first 5000s to a subfolder via the mv command? For now I move files with mv *some_pattern* ./subfolder1/ ...
3
votes
4answers
1k views

Searching a pattern in file names with number

I have a large number of files in a folder each with the date as the filename. For example 20130101 20130102 20130103 . . . 20130131 similarly for other months 20130201 to 20130230, the pattern is ...
4
votes
1answer
2k views

Why does grep sometimes show the file name, sometimes not?

Can somebody please explain to me why I don't get the full path in example 1? example 1 - returning found line grep MODIFY /opt/releases/packages/cr_c_cr6/sas/dbms/*/*; outcome: MODIFY example 2 ...
1
vote
3answers
259 views

Prevent wildcard expansion on find

Is there a way to prevent wildcard expansion on the find command so that the following would work? find . -iname "foo [bar]" As pointed out here, I tried running set -f, set -o noglob and setopt ...
1
vote
4answers
223 views

Exclude characters for SCP-filepattern

Is there a way to build an expression for scp with which I can manage to copy the file file-name-version-1.2.1.jar without copying the files file-name-version-1.2.1-sources.jar ...
0
votes
2answers
193 views

Regex and patterns on a ksh command line

I'm wondering what's the difference between using * and .* in a regex string. I guess, * stands for "0 to n characters" but I don't see what .* stands for. For example, what is the difference ...
7
votes
3answers
629 views

Remove all but one ( or more ) kind of filetype

I've been trying to find a command to remove all files in a folder but not a kind of filetype. But I seems to not have any luck. What I've tried so far : set extended_glob rm !(*.dmg) # this returns ...
6
votes
2answers
226 views

Why two almost idetical grep commands return different output: w/o and with filename

I have 2 almost identical greps: [Alex@localhost tmp]$ grep /bin/bash /etc/passwd root:x:0:0:root:/root:/bin/bash AlexL:x:500:500::/home/AlexL:/bin/bash user1:x:501:501:user1 ...
4
votes
2answers
6k views

ls *.* gives: “*.*: No such file or directory” message [duplicate]

I'm using Linux app-server 3.2.0-4-amd64 #1 SMP Debian 3.2.41-2+deb7u2 x86_64 GNU/Linux. When I go to a directory with several files named name1.php, name1.html, name2.php, etc. and type: $ sudo ls ...
7
votes
1answer
256 views

Cannot expand asterisk without proper permission

Can someone explain to me the following? $ ls -ld /temp/sit/build/ dr-xr-s--- 3 asdf qwer 4096 Jan 31 2012 /temp/sit/build/ $ ls -ld /temp/sit/build/* ls: /temp/sit/build/*: Permission denied So ...
4
votes
2answers
3k views

Bash globbing and argument passing

I have the following simplified bash script #!/bin/bash files=("$@") if [ "X$files" = "X" ]; then files=$HOME/print/*.pdf; fi for file in "${files[@]}"; do ls "$file"; done If I pass ...
3
votes
1answer
67 views

How to cd open / autocomplete a folder that ends in a specific phrase

I have a folder with subfolders named like this: 1122334 important things 1122335 less important things 1122336 notes 1122337 pictures of kittens etc The numbers at the beginning are date codes. ...
2
votes
2answers
244 views

Use xargs to move files from within a directory

I am searching for some folders in my current directory. What I want to do is, move all the files within those directories to another directory. I am using the following command: find -maxdepth 1 ...
1
vote
3answers
407 views

In a Bash if condition, how to check whether any files matching a simple wildcard expression exist?

Stupidly, I had been using a condition like this as part of a script: if [ $(ls FOO* 2> /dev/null) ] # if files named "FOO*" were downloaded then echo "Files found" # ... process and ...
2
votes
1answer
1k views

lftp exclude syntax confusion

I am confused with the syntax description given for lftp from their website: -x RX, --exclude=RX exclude matching files -X GP, --exclude-glob=GP exclude matching files How ...
3
votes
2answers
315 views

List all dotfiles current directory using zsh

How can I list all dotfiles in a directory using zsh.?
4
votes
2answers
241 views

Force Bash 4 'globstar' option to ignore symlinks

Bash 4 has a fantastic option called 'globstar' that emulates (i.e. was stolen from) zsh's ** syntax for globbing across multiple directories. However, it's somewhat crippled (for my usage, at least) ...
3
votes
3answers
535 views

copying specific files in directory

I am trying to copy some of the files in a directory. The directory contains following files my current directory is ~/certificate/ drwxrwxr-x 2 ubuntu ubuntu 4096 Oct 16 11:58 apache -rw-rw-r-- ...
2
votes
1answer
109 views

Why does copying from a script screw with my files?

I am at a loss here, trying to find out the reason why a shell script that is basically copying a couple of files and directories from one place to another will result in the content of two of the ...
2
votes
1answer
99 views

Why the order of wildcard results might be different when used from the terminal or from perl?

There's a folder with a bunch of files and a perl scrip that lists them using ls with a wildcard like: #!/usr/bin/perl system("ls -U -1 dir/*"); I noticed that if I run exactly the same command ...
1
vote
5answers
3k views

Find files by the length of filename

I want to find all files by length of the file names. For example if I want to find files of length 1, such as a.go, b.go I put: grep '.\{1\}' file But this does not work. What command can I use ...
1
vote
2answers
688 views

Way to write new filename on wildcard input?

I have some experience with Inix terminals from science internships I've been part of, mainly using a few utilities like grep, awk, and sed but there is one thing I've been trying to figure out for a ...
3
votes
2answers
698 views

How to copy multiple files but keep their extensions the same?

I am looping through a number of files, and $file represents the current file. How can I make copies or renames and keep the extension the same for this current file? e.g. if $file = x.jpg How to ...
0
votes
4answers
2k views

How to rotate all images in a directory with imagemagic?

I want to rotate all the images in a directory that match a pattern. So far I have: for file in `ls /tmp/p/DSC*.JPG`; do convert $file -rotate 90 file+'_rotated'.JPG done but that gives no ...
0
votes
1answer
63 views

Does wildcarding significantly hurt BIND Performance?

I have enabled RPZ on my BIND 9.9.4 DNS server and I wanted to be able to wildcard some records in my RPZ zone, but I am afraid of the performance hit this might cause. Does anyone out there have some ...
3
votes
1answer
197 views

Why is `find -name *.jks` not returning some files? [duplicate]

find . -name *.jks -print 2>/dev/null returns files of extension jks that do not have underscores as part of their name. Much to my surprise, I have just discovered that * does NOT substitute ...
5
votes
2answers
814 views

Copy all dotfiles except for `.git` and `..`

I am aware of using .[!.]* to refer to all dotfiles in a directory with the exception of .., but how might one refer to all dotfiles except for .. and .git? I have tried several variations on ...
28
votes
1answer
2k views

Does 'rm .*' ever delete the parent directory?

The expression .* is expanded by bash to include the current and parent directories: $ ls -la total 2600 drwxrwxrwx 2 terdon terdon 2162688 Sep 10 16:22 . drwxr-xr-x 142 terdon terdon 491520 Sep ...
2
votes
2answers
135 views

Discrepancy between the two expansions

If you input the command ls * and echo *, you will notice the remarkable discrepancy between the results. The former recursively includes while the latter totally excludes files in subdirectories. ...
4
votes
4answers
2k views

cp hidden files with glob patterns

Situation : $ mkdir foo && touch foo/.test $ cp foo/* . zsh: no matches found: test/* (or bash : cp: cannot stat ‘test/*’: No such file or directory) I have a directory full of hidden ...
5
votes
1answer
120 views

“globbing” (*) comes from “global command”… Huh?

According to legend, in the early days what we now call "globbing" (i.e. using expressions like e.g. *.c, ./*.p?) was supported by one certain program /etc/glob, whose name in turn derived from ...
3
votes
4answers
3k views

How do I select files in a bash script that do not have an extension?

Let's say I have files xinitrc, alphabetsoup, ieat.pie in the current directory. Need a bash script to select only xinitrc and alphabetsoup.
2
votes
4answers
4k views

Shell script to check for the presence of one or more files with a specific extension?

I want to write a script to find a file with specific extension.this much i have done: #!/bin/bash file="/home/Savio/Dsktop/check/*.csv" file1="/home/Savio/check/*.txt" if [[ -f "$file" && -f ...
3
votes
1answer
132 views

watch command to delete files in a directory every N secs

I thought of using watch command to delete files in a directory every N seconds with the command running in background. This is what I was planning to use: nohup watch -n1200 rm -rf ...
8
votes
5answers
4k views

cp with a single argument containing wildcards [duplicate]

If I have the following 2 files and 1 folder: someuser@computer:~/Desktop/test$ ls -l total 340 -rw-r--r-- 1 someuser someuser 45082 ago 5 09:56 file1.pdf -rw-r--r-- 1 someuser someuser 291836 ago ...
6
votes
1answer
6k views

delete files matching pattern

I need to recursively remove all files in all subdirs where the filename contains a number followed by an 'x' followed by a number, at least two times. Example: I'd want to remove these files: ...
17
votes
5answers
3k views

What does `mv ./*` without specifying destination do?

I accidentally forgot to specify destination before hitting the Return key. Where does mv ./* without specifying destination move the files and directories under current directory to?
3
votes
1answer
2k views

Using regex in ls and mv

I have a directory structure like this ├── UK │   ├── BuyBand_go_UK.png │   ├── BuyBand_go_UK.svg │   ├── BuyBand_K.png │   ├── BuyBand_K.svg │   ├── BuyBago_UK.png │   ├── BuyBago_UK.svg │   ├── ...