Globbing means matching files by name patterns containing wildcards.

learn more… | top users | synonyms (2)

0
votes
1answer
38 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
155 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
176 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
416 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
162 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
81 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
113 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
47 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
65 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
54 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
198 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
46 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
89 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
117 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
112 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
510 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
504 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
364 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
61 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
49 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
711 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
420 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
81 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
83 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
686 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
98 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
2k 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
108 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 ...
2
votes
1answer
2k 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
164 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
414 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
240 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
113 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
148 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 ...
3
votes
2answers
241 views

Is there a reason to use multiple question marks instead of an asterisk in filename expansion?

If I have a number of directories, named, for example 10001 through 10025 is there any reason to use ls 1*/foo vs. ls 100??/foo? I have a lot more than 25 of them, so I mostly curious if there's any ...
2
votes
2answers
256 views

Cygwin using wildcard to trim all images

Unortunately, I am forced to use windows. So, I installed Cygwin to use some Linux commands. The following command works fine. It replaces an image with its trimmed version. "C:\Program ...
-1
votes
1answer
53 views

Assign regular expression as character for a variable

I am wondering is there is a way to assign a regular expression as a character in a string to a variable and not have the regular expression change my variable. For example: in my directory I am ...
2
votes
3answers
593 views

!(*.sh) works on the command line but not in a script

When I use the code below in a terminal on Ubuntu, it works fine: rm !(*.sh) -rf But if I place the same line code in a shell script (clean.sh) and run shell script from terminal, it throws error ...
1
vote
2answers
53 views

zsh - complex filename matching [closed]

I have trouble passing a list of file names to a program when utilizing globbing operators. Essentially the problem is that I have files with multi-stage suffixes and I want to match only the master ...
0
votes
0answers
41 views

What does the double star/asterisk wildcard expand to? [duplicate]

For example, Where are your test specs located? (./test/specs/**/*.js) Will that descend in all subdirectories under ./test/specs/, recursively? What authoritative source discusses this ...
1
vote
2answers
138 views

Piping contents of multiple files between programs while keeping contents separate

I would like to read in a number of files and pipe their output to subsequent programs while still maintaining them as individual pipelines of data. program1 *.txt | program2 | program3 folder I ...
2
votes
3answers
259 views

Copy only directories with .mp3 files with rsync

I'm trying to copy only folders with .mp3 files in them to another device. And only the .mp3s in them. The structure looks like this: Band/Year - Album/*.flac Band/Year - Album/*.txt Band/Year - ...
1
vote
1answer
319 views

du reports directory size as much bigger than the sum of its contents

Running du -shc * in the top directory gives 110G for a particular folder, whereas running the same command inside that folder gives a total size of 11G. How is that possible? Platform Details: OS: ...
1
vote
1answer
130 views

Copy array of multiple files with globbed extensions, in bash 3.2

I've found bits and pieces of each of the things I want to do across the Web, but nothing exactly fits my use case. I'm trying to write a script that copies multiple specific files to a directory on ...
2
votes
3answers
345 views

reverse cat files order

I need to do log analysis and I am facing problem that cat access.log* display latest log file first. I tried to sort logs which takes a lot of time because I have logs from couple of years back. And ...
2
votes
1answer
153 views

Unable to get back to bash prompt after strange command

I was messing about with different wildcards and ran the following command: ls testdir/!(*/) after which I was completely unable to get back to the bash prompt. None of ^C, ^D, or even ^Z worked: ...
1
vote
1answer
42 views

Handle wildcards matching no file in bash

I am trying to read files from a directory into an array but even when the file doesn't exist, it is saved into the array. I want to exclude the file name if it doesn't exist. a=(/tmp/nofileexists) ...
1
vote
1answer
153 views

Listing directories and understanding ls

On ls man page, I saw this -d, --directory list directory entries instead of contents, and do not dereference symbolic links on my current folder: drwxr-xr-x 2 oracle oinstall 4.0K Jul ...