Globbing means matching files by name patterns containing wildcards.

learn more… | top users | synonyms (2)

0
votes
2answers
86 views

For loop cannot distinguish * syntax

set -x for f in ~/1/2/*/*_1.txt; do subdir="${f%/*}" pushd "$subdir" &>/dev/null file="${f##*/}" expTool INPUT1= "${f##*/}" INPUT2= "${f%_1.txt}_2.txt OUTPUT1= "${f%_1.txt}_3.txt" OUTPUT2= ...
5
votes
2answers
39 views

How to store a path built with wildcards and containing with spaces into a variable

Here's the situation (I'm on a Mac, OS X El Capitan): # This works: $ cd /Applications/Adobe\ Illustrator*/Cool\ Extras.localized/en_US/Templates/; # These do not work: $ ...
2
votes
2answers
24 views

exclude target redirection file from being processed in for loop

This will cause LIST to grow very large (even a couple of GB in a short time etc): $ for i in *; do echo $i; cut -d ' ' -f1 $i ; done > LIST For example, after 10 seconds: $ wc -l LIST ...
2
votes
2answers
57 views

How to copy image files whose names don't end with their resolution size?

I have a folder with images in it and it is organized by year and month folders (ie. /2015/08/image.jpg). Whenever an image is added, it is also copied and resized like so: image-1024x768.jpg ...
3
votes
1answer
20 views

Rsync unable to remove remote file not exist in local

Consider my local folder /tmp/foo/ /tmp/foo/1.txt /tmp/foo/2.txt /tmp/foo/3.txt and my remote folder /tmp/foo/ /tmp/foo/1.txt /tmp/foo/2.txt /tmp/foo/4.txt and in my local side, I run the ...
1
vote
1answer
42 views

How to prevent bash from transforming arguments?

I am trying to use an argument of the script to find other files. The problem is that when i give the script the argument x.* in the command line, it is transformed into x.sh. Any ideas how i can get ...
0
votes
2answers
29 views

How to exclude the files with all the 4-digit numbers without the first five numbers by wild card in tree command

I want to exclude list the following number 0005 0006 ... 9998 9999 I try the following code, but failed And I use tree -I '*.[0-9][0-9][0-9][5-9]' But It creates line with 0014 0024... I ...
0
votes
2answers
31 views

Why doesn't this find command work? Regex & Find variants for .mp3 .wav and .m4a files

2015.10.25 Move on and Be Blessed.wav dummy.m4a 2015.11.17 BS Full.wav.mp3 2015.11.17 BS MOL.wav.mp3 find . -name '*.mp3' -o -name '*.wav' -o -name ...
2
votes
4answers
50 views

Does directory match array variable

I'd like to check to see if a directory contains an array of file extensions. I'm on Ubuntu using Bash. Something like : files=$(ls $1/*) extensions=$( txt pdf doc docx) if [[ -e $files[@] ...
0
votes
2answers
58 views

tar “--exclude-from” double star wildcard

I wrote a backup script on my Debian 8 system which uses tar command with "--exclude-from" to exclude some files/dir. This works great, but today I would like to exclude some files sharing the same ...
0
votes
1answer
30 views

What's the equivalent wildcard operator in Zsh to Bash's *

I have just started using Zsh and I have noticed that the asterisk (*) wildcard operator does not seem to work in it. For example, running cd ~/Doc* does not change me into the ~/Documents directory ...
1
vote
1answer
48 views

find command match issue [duplicate]

I'm having some trouble while searching files with find command and the way it handles the search. Let's say I'm currently in the directory /tmp and the directory contains the files: ...
1
vote
1answer
36 views

globbing and $# [closed]

Suppose my shell script gets 3 arguments: ./myscript dir1 material dir2 I need $# to report the count of items globbed with dir1/* and not the count of my script's original 3 arguments. Do you ...
3
votes
1answer
189 views

Odd alias “find . -name '*\!{*}*' -ls” in Unix Power Tools

From Unix Power Tools 3rd Edition page 175: Article 9.27 shows a way to match directories in the middle of a path. Here's a simpler "find file" alias that can come in very handy: alias ff ...
0
votes
1answer
23 views

Head and Tail of a directory, set by the user

I have this script that will show the user the head or tail of the files that are inside a set directory (currently that is set as '~/bin/new/*'). This script works but i would like to allow the user ...
2
votes
2answers
113 views

Role switch of special characters in bash

On what basis does the role of asterisk keep changing? CASE 1: var1=abcd-1234-defg echo ${var1#*-*} # RESULT: 1234-defg CASE 2: stringZ=abcABC123ABCabc echo `expr match "$stringZ" ...
0
votes
1answer
61 views

scp with sshpass - remote directory and file with wildcards

I have a list with 950 MongoDB VMs I wish to collect all mongodb.log. The path to log file is depending on database name. for i in $(cat /tmp/mongonodes.txt) ; do sshpass -p34dDgdWger@rg4fll434ef ...
2
votes
3answers
363 views

Why rm exclude using ! doesn't work in zsh?

I have 10 files in current directory: 10test 1test 2test 3test 4test 5test 6test 7test 8test 9test I want to remove all file except 2test and 3test, but I run command rm !(2test|3test) doesn't ...
0
votes
0answers
40 views

rsync “no such file or directory” when using wildcard

I am trying to use rsync to copy the contents of a folder to another folder. This is the command I am using for this. rsync -v -r $folder64/Pictures/* $folder65/Pictures/ And here is the error ...
2
votes
1answer
66 views

bash regex: asterisk gives ambiguous search results with grep

I am using a simple text file to test the * meta-character through grep. The text file is as below: 1 11 111 1111 11111 111111 d da daa daaa b bc bcc bccc Now when I search digit 1 using grep ...
0
votes
2answers
21 views

file globbing in bash not being picked up by php -l

I am trying to run php's lint function on all files in a directory, and it's proving to be harder than I expected. (I know there are non-php files here; I'm not concerned about that right now.) Here's ...
3
votes
4answers
80 views

Why does the wildcard * not work when changing directories?

For example I'm in my directory: /home/myname and then I want to CD into a different directory. /home/pulsar/... Since I need to go pretty deep into the other directory, how can I go about this ...
2
votes
1answer
28 views

How to reuse file pattern in .gitignore in bash/zsh?

Here is the content of the .gitignore cron.yaml build target webview *.pyc *.sublime-workspace .idea *.rej .coverage app/tools/temp_*.py app/tools/*/temp_*.py I am currently iteraring files in a ...
1
vote
2answers
47 views

Internal expansion with the find command and wildcard character [duplicate]

I'm still learning the command line and I am having some trouble fully understanding the use of the wildcard within the find command. I'm working in the directory user/temp and use the find command ...
2
votes
3answers
48 views

Recursively delete files with 'WIDTHxLENGTH' in the name in a directory

I have a directory that has subdirectories, and I want to delete images named like thumbnail-name_WIDTHxLENGTH.{jpg,png}, where WIDTH and LENGTH are both decimal integers, like box-image-150x150.jpg ...
3
votes
4answers
157 views

Match-zero-or-more operator in shell globbing

I'm stuck in a quite trivial problem here: how can I make the * symbol in bash mean zero or more, like it does in tools such as sed? For example, ak* should match any file whose name consists ...
1
vote
1answer
40 views

Having trouble with img2pdf and spaces in filenames

I am trying to convert a bunch of jpeg files to a pdf file. When I type the filenames with the quotes all is fine: $ img2pdf "./Page 001.jpg" "./Page 002.jpg" -o book.pdf When I go for the ...
1
vote
3answers
74 views

What is the bash equivalent of the where cmdlet?

The where cmdlet is something I use in PS quite often- its very convenient. If I want to get all files with a name starting with "test" I would do this: ls | ?{$_.name -like 'test*'} What is an ...
3
votes
3answers
86 views

Why are square brackets preventing shell expansion?

'4800483343' is a directory, and 'file1' & 'file2' are two files in it. Why is the following happening? $ ls 4800483343 file1 file2 $ md5sum 4800483343/* 36468e77d55ee160477dc9772a99be4b ...
3
votes
1answer
106 views

Ignore globs that don't match anything

I want to select all files in a directory that end with any of the following extensions: txt, java, xml, csv Right now I'm doing like this: echo *.{txt,java,xml,csv} The problem is, if the ...
8
votes
6answers
401 views

Force newlines with cat wildcard printing

I want to use cat with wildcards in bash in order to print multiple small files (every file is one sentence) to standard output. However, the separate file contents are not separated by a newline, ...
3
votes
2answers
265 views

Regex file name with multiple digits

Say I have the following file: test_file-1234-master.tar.gz I have tried to un tar using the following commands tar -xf test_file-[0-9]+-master.tar.gz tar -xf test_file-[:digit]-master.tar.gz ...
5
votes
3answers
276 views

Use shell's “*” glob, but exclude one file and don't match directories?

I've got a makefile rule that builds a zip/tarbar for distribution. In the recipe, it does some "value added" things, like ensure CR/LF's are correct, and ensures execute bits are correct before ...
0
votes
1answer
57 views

Why is the redirection of loop output dependent on the filename?

I have two files: a.csv and b.csv: echo $'a_header\na1' > a.csv echo $'b_header\nb1' > b.csv Now I want to remove the first line from each, and concatenate them. for file in `ls *.csv`; do ...
1
vote
1answer
42 views

Can I use Zsh's built-in wildcard matching to replace the use of `find` here?

This is a follow-up to another question I posted I use a script to automatically rename files according to a particular order: #!/usr/bin/env zsh pages=($(sed -n '/page_order/,/^$/ p' _config.yml | ...
1
vote
4answers
272 views

How to list filenames that contain spaces and special characters without using find

I am writing a script that requires me to provide a list of files in my directory, whose filenames contain spaces,*,?,$,%,etc. How can I do this, I have seen multiple posts but couldn't find anything ...
1
vote
4answers
248 views

Bash: move files of specific pattern

I write a script that iterates over a set of zip files, extracts them and moves only files that match a specific filename pattern to another folder. The script: #!/bin/bash ...
4
votes
3answers
61 views

Move unique files from a folder with duplicates files

Well to put it simply, I have duplicate files in a folder, with this form: file.ext file(1).ext file(2).ext file(3).ext otherfile.ext otherfile(1).ext otherfile(2).ext ... I want to move only ...
1
vote
2answers
56 views

Cannot run command inside bash variable including square brackets with nullglob

Assuming I want to run commnand stored inside the variable with nullglob turned on. For example: shopt -s nullglob a="echo [foo]bar" ${a} This gives me an empty output due to the nullglob option of ...
24
votes
1answer
611 views

Why does a unquoted wildcard work remotely with scp?

I'm typing this in Bash: scp user@remote:~/dir/*.xml . and it works, getting all the files that make the wildcard on the remote server. But why does this work? I thought that Bash expands wildcard ...
1
vote
2answers
69 views

List files in hierarchy of directory

I need to list files in hierarchy of directory. For that I wrote script like foreach file ( * ) ls ${file}/*/*/*/*/*.root > ${file}.txt end But for this I have to know that in the directory ...
28
votes
6answers
3k views

Why does [A-Z] match lowercase letters in bash?

In all shells I am aware of, rm [A-Z]* removes all files that start with an uppercase letter, but with bash this removes all files that start with a letter. As this problem exists on Linux and ...
3
votes
2answers
1k views

tar command - skip symlinks

I use the tar command as, tar -cvf protTests.tar protTests/* to tar all files inside the folder, protTests. But this is including the symbolic links inside the folder, which is not a desired one. ...
0
votes
0answers
54 views

how to exclude specific subfolder when creating zip file via command line linux

I do want to exclude subfolder like uploads/2015/OtherSubfolderName through command line. I have tried with below command, its working fine. zip -r zipfile.zip public_html -x *uploads* but can we ...
1
vote
1answer
862 views

Check if multiple files exist in directory

How to find multiple files present in a directory in ksh (on AIX) I am trying below one: if [ $# -lt 1 ];then echo "Please enter the path" exit fi path=$1 if [ [ ! f $path/cc*.csv ] ...
2
votes
3answers
140 views

List transient files by numerical value having number greater than a given constantly varying filename

I've a directory having constantly changing filenames (by numerical value) listed as: -rw-rw----. 1 root root 10493952 May 7 10:39 A0000000.LOG -rw-rw----. 1 root root 10493952 May 7 08:38 ...
0
votes
1answer
217 views

find delete shows “No such file or directory”

I just run a command to "find and delete files & folder older than 100 days" on a folder, and got the following: $ find . * -mtime +100 -delete find: May_01_2015: No such file or directory find: ...
1
vote
3answers
140 views

Copy filenames, and add path prefix, in a directory, recursively

I have a working directory: /home/myusername/projectdir The working directory contains files and sub-directories. The depth of sub-directories is not known. I want to put all the *.log files into the ...
0
votes
4answers
89 views

How can I test for the .RAW file extension?

I'm trying to set up an sh script that will run every 30 minutes. During each run, I want to check a directory for the presence of at least one .RAW file. Upon finding that file extension, I will have ...
0
votes
3answers
125 views

regex in `/bin/sh` shell

I would like to remove all files ending with a given set of extensions in a particular directory in a /bin/sh shell. With a /bin/bash I can do it with regex like this : rm path/(*.pdf|*.png) but ...