Globbing means matching files by name patterns containing wildcards.

learn more… | top users | synonyms (2)

6
votes
1answer
101 views

Exclude one pattern from glob match

I have several files with the same base filename. I'd like to remove all but one foo.org #keep foo.tex #delete foo.fls #delete foo.bib #delete etc If I didn't need to keep one, I know I could use ...
2
votes
2answers
22 views

Specifiy Unix TimeStamp Range in Parameter

I am launching a mrjob in bash and need to pass in as parameters a range of gz files which have unix time stamps in them as: filename_9127381923.gz. How to do this in the simplest possible way? I can ...
0
votes
2answers
114 views

proper way to iterate through contents in a directory [duplicate]

I need to iterate through every file inside a directory. One common way I saw was using the for loop that begins with for file in *; do. However, I realized that it does not include hidden files ...
1
vote
1answer
21 views

How to copy with wildcard in directory name?

I would like to copy the html directory inside a directory like cms_drupal_PROJ-1-2 to /var/www. The last digit in the working directory is dynamic so at any given time all I know is ...
2
votes
4answers
201 views

Passing wildcard * to a (bash?) script [duplicate]

I want to to remove all color codes which look like '@n', '@R' etc, from a moderately large size collection of text files. So in a file called 'remove_cc', I wrote the following: sed -ie 's/@r//g' ...
24
votes
8answers
2k views

Dealing with file names with special first characters (ex. ♫)

I have recently come across a file whose name begins with the character '♫'. I wanted to copy this file, feed it into ffmpeg, and reference it in various other ways in the terminal. I usually ...
1
vote
1answer
23 views

Wildcards in exclude-filelist for duplicity

I am trying to exclude a "bulk" folder in each home directory from the backup. For this purpose, I have a line - /data/home/*/bulk in my exclude-filelist file. However, this doesn't seem to be ...
0
votes
1answer
49 views

move files of a particular pattern to another directory

In the directory /home/in I have files like this: crust.MC12345.txt crust.etcMC12345.txt crust.MC23456.txt crust.etcMC23456.txt crust.etctcMC23456.txt I only need to move crust.etcMC12345.txt ...
0
votes
1answer
58 views

Unix: What happens if I enter ls -d [2-q]*

Would it just ignore the bit after the -d option since you cant arrange characters lexically between 2 and q?
0
votes
1answer
77 views

Copying files with multiple extensions

I would like to copy files with multiple extensions to a single destination directory. For example, I can use the following command to copy all .txt files in the working directory to a directory ...
1
vote
1answer
41 views

du skip symbolic links

I cannot find an example of what I want to do and, from what I'm reading, the default behavior of du on my system is not the proper default behavior. If I ls my /data folder, I see (removing the ...
2
votes
2answers
44 views

Wildcard for arbitrary depth

I want to use grep where paths are arbitrary depth under the directory /path/to/dir and has the file name foo. I thought that the wildcard for arbitrary depth is **, and I tried grep some_pattern ...
5
votes
3answers
149 views

Bash script error with strings with paths that have spaces and wildcards

I am having trouble getting the basics of Bash scripting down. Here's what I have so far: #!/bin/bash FILES="/home/john/my directory/*.txt" for f in "${FILES}" do echo "${f}" done All I want to ...
3
votes
4answers
58 views

How can I get the first match from wildcard expansion?

Shells like Bash and Zsh expand wildcard into arguments, as many arguments as match the pattern: $ echo *.txt 1.txt 2.txt 3.txt But what if I only want the first match to be returned, not all the ...
2
votes
1answer
99 views

Bash: Syntax Error on @()

I have the following function in my .bashrc file: extract() { local c e i (($#)) || return for i; do c='' e=1 if [[ ! -r $i ]]; then echo "$0: file ...
2
votes
1answer
25 views

search files using group permission

If i need to search files using group permission I use the following command echo **/*(AIE) where AIE stand for read/write/execute. For owner and group permissions the qualifier used are rwx and ...
-3
votes
1answer
82 views

Find files using ls and wildcards

pwd : ../bin under bin I have a directory called datafiles. Use meta characters and the ls -lL command (with lower and upper case L) to list all filenames under the datafiles directory that contain a ...
1
vote
2answers
55 views

Find doesn't want to find *.sh in certain level [duplicate]

I have a problem with find. It doesn't find *.sh files if I am in certain directory level. It does, however, find *.sql files. /path$ cd do_not_upload/updates/1.1.1/ ...
12
votes
3answers
2k views

Why does [a-z] asterisk match numbers?

I have 3 directories at current path. $ls a_0db_data a_clean_0db_data a_clean_data $ls a_*_data a_0db_data: a_clean_0db_data: a_clean_data: $ls a_[a-z]*_data a_clean_0db_data: a_clean_data: I ...
1
vote
2answers
62 views

Apply given rsync exclude patterns on given directory

I have a setup where I use rsync to mirror some source directory to a (remote) destination except for some files and locations defined witch rsync exclude patterns: # Useless files - thumbs.db - *.~ ...
3
votes
2answers
93 views

Loop in WildCard as Input of Script

I want to use my script on many files sometimes. I used this for the purpose: for etminput in $1 do #process done But this just gives the first input. How can I do the process on every ...
1
vote
3answers
70 views

bash/shell pathname expansion for mkdir, touch etc?

So doing something like this in bash and most other shells won't work to create multiple subdirectories or files within subdirectories... mkdir */test touch */hello.txt There are of course many ...
1
vote
2answers
51 views

Why asterisk in command result in for loop is expanding?

I want to write a script that will run git diff --name-status master..<BRANCH> but when I run this: for i in $(git branch | grep -v master); do echo $i; done I get echo one directory ...
2
votes
1answer
52 views

How to use " rm !(*keyword) in bash 4.1.2?

I got bash 4.1.2 on remote centos machine. When using my favorite rm !(*keyword) I got bash: !: event not found I tried to upgrade its bash, but seems the edition remains after upgrade. The ...
4
votes
2answers
68 views

Disable glob qualifiers in zsh

Is there a way to disable glob qualifiers with zsh? It seems like a useful feature, but it gets in the way of normal parentheses. I use ag to search files, and ag mymethod(param) causes zsh to ...
1
vote
3answers
238 views

Why is ls command slow to interrupt on NFS directory with lots of files?

I noticed in directories with lots of files on NFS if I do ls * then hit Ctrl-C it can take a while ( say 20 seconds ) before ls comes back. Why? Can ls command be fixed to be more responsive?
1
vote
1answer
50 views

Expand shell variable without globbing

I want to check whether an input string refers to a file name - not a wildcard string like *.txt. This doesn't work: if [ -f "$1" ]; Because $1 gets expanded to *.txt, which gets expanded to, say ...
0
votes
1answer
83 views

ls command - list files containg speccific string in file name and belong to specific type

I am new to linux. Is it possible for a ls command to return a list of files containing "PRO" in its file name and belong to pli file type. I have researched and identified that ls -c -lt *.PLI will ...
2
votes
2answers
70 views

Is a ? treated in a special way in parameter expansion?

I'm attempting to parse to output from git status --porcelain -b for use in my prompt but I'm coming across strange behaviour when performing parameter expansion. This snippet should demonstrate the ...
3
votes
4answers
260 views

Make many subdirectories at once

Suppose I have a directory /, and it contains many directories /mydir, /hisdir, /herdir, and each of those need to have a similar structure. For each directory in /, there needs to be a directory doc ...
2
votes
2answers
168 views

Bash copy all files that don't match the given extensions

When I import pictures from my camera in Shotwell, it also imports the video clips. This is somewhat annoying, as I would like to store my videos in another folder. I've tried to write a bash command ...
2
votes
2answers
47 views

Select a range of files after sorting them

One thing I notice slower for me if I switch from using a GUI file manager to CLI is: In a GUI file manager, I can quickly select a subset of files under a dir by, first sorting them according to ...
3
votes
2answers
79 views

Move every file that is not a directory

I have a directory that I am trying to clean out that contains both files and subdirectories. What I am trying to do is simple: move all the files into another directory, but leave all the ...
2
votes
3answers
295 views

Count files in a directory by extension

For the purpose of testing, I'd like count how many images files are inside a directory, separating each image file type by file extension (jpg="yes". This because later it will be useful for another ...
1
vote
1answer
43 views

processing multiple extensions

I have done a script to convert recursive .jpg files to another size: echo $re mkdir "$re"_tmp for a in *.jpg ; do convert "$a" -resize $re "$re""_tmp/${a%.*} ["$re"].jpg" ; done I'd like integrate ...
3
votes
2answers
161 views

Valgrind /usr/lib files are not regular Linux files

The problem that I encountered today (on an embedded device with Linux) is that some files (specifically, the Valgrind /usr/lib files) are behaving very strange and they are not copy-able with scp ...
2
votes
1answer
73 views

rsync specific directories

Below are the directories of my directory structure. I only want to run rsync on the content under the archive directory of any subdirectory and exclude everything else: ./ ap/ ap/aploader/ ...
4
votes
5answers
427 views

Bash pattern to match all files but directories

In bash, how do I specify a pattern that matches everything but subdirectories in current directory. Given that the pattern */ matches all the subdirectories, I tried (with extglob turned on): $ echo ...
3
votes
1answer
558 views

find files without extension

Let say I have: foo.txt bar baz.ooo If I use ls -1 !(*.*) then I'll get only bar on the output. Great, now I wish to have same results with find - some find -regex that will do the job. NOTE: ...
0
votes
3answers
100 views

find command: -or option doesn't work

I want to execute a command for an each file that matches a pattern. But the command that seems to be right, doesn't work for me, I have no idea why. $ find . -type f -name '*.c' -or -name '*.h' -or ...
2
votes
2answers
49 views

how to filteri by asterisk or similar expression by rsync in zsh

I have a lot of files named like: /var/log/foo/2014-07-06-01.log ... /var/log/foo/2014-07-20-04.log Everyday I have several log files and I want to download specified day's log files: $ rsync ...
1
vote
3answers
64 views

List files in a directory with a certain extension

I created a file called ~/usrlibs.txt, which contains the number of files that begin with lib and end .a found in the /usr/lib directory. I tried: ls -l /usr/lib/lib .a | wc -w > ~/usrlibs.txt ...
1
vote
2answers
65 views

Problems with basename in a loop

I am new at shell script programming and I'm trying to execute a software that reads a text and perform it's POS tagging. It requires an input and an output, as can be seen in the execute example: $ ...
-6
votes
2answers
494 views

Shell script to compile C files

I used to have a shell script that would compile all of the FILE.c files in a directory to FILE.out I lost it and am trying to remake it and have the following which I know is very similar but can't ...
1
vote
2answers
337 views

Aix grep wildcard not working

I have a file called message that has the line CSC/UT/USA/WBIMB/SAP/orders05:orders05/ORDERS05/NONE/ORDRSP/758 I am doing a grep (Platform is AIX 6.1) grep ...
3
votes
3answers
126 views

History of Bash globbing

Is there a historical reason why Bash "globbing" and regular expressions are not identical? For example, I believe that in Bash [1-2]* matches anything that starts with a 1 or a 2 followed by anything ...
3
votes
2answers
140 views

Error when calling mv with wildcards

#! /bin/bash error_text=$(tail -n +1 /path/dir/folder/exc/a/update/Abd/ER/* | \ grep 'Warning\|Loaded\|Event') echo $error_text nc 10.10.99.45 25 << EOF ehlo mail.abc.pvt mail from: ...
0
votes
3answers
64 views

find * looks for a file named “*” on Debian but not on RHEL

Where is the difference? Do these distributions handle something differently? Or does the configuration vary? What do I have to compare and adjust? I would prefer find * not to match the wildcard ...
1
vote
1answer
92 views

Globbing with * in Bash - Debian vs RHEL [closed]

Where is the difference? Do these distributions handle globbing differently? Platforms: Debian Wheezy 7, Red Hat Enterprise Linux 7. Bash is always used. In my example, cat prints every file in /etc ...
4
votes
4answers
280 views

What is the Linux command to display how many file names in the directory end in two digits

What is the Linux command to display how many file names in the directory end in two digits? Using ls with a command like this : ls -l | wc –l *[0-9][0-9]