Globbing means matching files by name patterns containing wildcards.

learn more… | top users | synonyms (2)

3
votes
1answer
42 views

Parameter expansion in variable assigned with a wildcard

I have two files in my current folder (MA502) whose names are - MA502_TAAGGCGA-TCGCAGG_L001_R1_001.at.fastq MA502_TAAGGCGA-TCGCAGG_L001_R2_001.at.fastq I have many such folders - ex MA503, MA504 ...
2
votes
3answers
235 views

copy all files that have no extension

We can copy some file by extensions like this: cp *.txt ../new/ but how can I copy all files that have no extension?
0
votes
3answers
57 views

Creating a script that runs a simple command for all files in a directory

I need to use the text-based browser Lynx to dump 1000s of html files into text files, with the same filename. For any given filename.html the command is lynx filename.html --force-html --dump > ...
2
votes
3answers
97 views

Delete several sequential file names, but ignore part of the first

Sometimes, my scripts get trapped in infinite loops. When the loop creates new files, things get messy. I currently have this file name format: Task.4883.store.log where 4883 is a counter. I ...
2
votes
3answers
38 views

grep .* returns results from .bash_history and complains about

I'm new to Linux and so far I've been playing around with some utilities, specifically the grep utility. I decided to create a new file (aptly called 'newfile') with the following content: Lady of ...
3
votes
1answer
126 views

Bash substitution with variable defined from a glob pattern

The below example explains the issue. Why is the FILENAME printed correctly when echoed and perceived as a pattern when using substitution? #!/bin/bash FILEPATH_WITH_GLOB="/home/user/file_*" ...
3
votes
1answer
69 views

Filename Expansion: Find Utility Pattern Matching vs Bash Shell Pattern Matching

For filename expansion, the 'find' utility's '-name' option seems to function similarly, but not exactly the same as the bash shell's builtin pattern matching. Here are the relevant sections of the ...
4
votes
2answers
110 views

Difference between find ~ and find *

What is the difference between find * and find ~ for searching a file? In terminal when my present working directory on root,then in terminal root@devils-ey3:~# find * -print -quit ~ On same ...
1
vote
1answer
86 views

Why is Bash returning “No such file..” when pattern matching this string?

I have the following for loop: for f in ~/.lo-rcs/common/* do . $f done which is returning this error: bash: /home/sk/.lo-rcs/common/*: No such file or directory I keep classifying my bashrc ...
20
votes
9answers
2k views

Find files whose name is 4 characters long

I would like to find files whose name has only 4 characters. Example, there are three files under /tmp: $ ls /tmp txt file linux Output should only show file because it only has 4 characters.
0
votes
1answer
44 views

tar exclude files *.zip

Why don't *.zip patterns work in tar : tar cfjv backup.tar.bz2 --exclude mydir/files/*.zip mydir Is there another syntax?
1
vote
3answers
56 views

Find a file with the extension .csv in a directory matching a pattern

I have a folder in which I have many subfolders. The Root folder name is allCSV and sub foldername is will be like a_date(s), b_date(s), c_date(s) ... I want a file which is in a_date(s) and ends ...
1
vote
2answers
67 views

Copy .txt files in a certain directory

I have an issue in copying my file in my directories. I have .txt and .jpeg files in a lot of directories, and I want to copy only the .txt files according to the directory. For example, I have this: ...
10
votes
1answer
157 views

Why is nullglob not default?

In most shells nullglob isn't the default. That means, for example, if you run this command ls * in an empty directory, it will expand the *-glob to a literal ' * ', instead to an empty list of ...
4
votes
4answers
83 views

Searching file in a directory through bash script

I have written the following code to search all the file names in the current working directory that contain the letter 'f'. for i in * do echo $i if [ $i = "*f*" ] then echo "no" else ...
6
votes
2answers
148 views

Extended Glob: What is the difference in syntax between ?(list), *(list), +(list) and @(list)

I have a question after reading about extended glob. After using shopt -s extglob, What is the difference in the following? ?(list): Matches zero or one occurrence of the given patterns. *(list): ...
1
vote
2answers
70 views

Why can't unrar expand this expression?

I had three RAR files in the same directory: file1.rar, file2.rar and file3.rar. I wanted to extract them with one command using expansion, bearing in mind that asterisks have to be escaped in ...
4
votes
4answers
460 views

List all the files ending with 10 or 11 or 12

To list all the files ending with 10 or 11 or 12 I have tried ls *[10-12] and ls *[10,11,12] but these are not working. I don't know why. Can anyone help me?
5
votes
2answers
161 views

scp command behaves differently when used with expect utility

expect -c 'spawn scp -C -o CompressionLevel=9 ~/partFiles/* abc@10.200.4.15:/export/home/abc/; sleep 10; expect password; send "secretPassword\n";interact' throws - ~/partFiles/*: No such file or ...
0
votes
1answer
15 views

updatedb.conf, Ignore files using pattern match/globbing

Running locate command with a file name returns multiple entries as, a.py a.pyc a.py~ Obviously, i am not looking for binaries/compiled files. I tried to configure locate command to ignore files ...
2
votes
2answers
58 views

Does zsh expansion work differently in non-interactive scripts?

I'm currently working on a pretty simple zsh script. What I often do is something like: mv */*.{a,b} . When I run that within a zsh script, it seems to expand differently and fail while it works in ...
8
votes
1answer
264 views

Bash wildcard to match exactly n characters

Is there a wildcard in bash to match exactly 5 characters, shortening a pattern like ?????
2
votes
3answers
151 views

tar unix not changing directory

I am executing a tar command to compress files which are present in another directory. I executed following command: tar -czf /backupmnt/abc.tar.gz -C /backupmnt/statusService/ * I want to create ...
6
votes
2answers
166 views

Exclude one directory in `ls` matching pattern

I'm trying to ls dirs that have .png files inside (no need for recursiveness, though it would be extra useful), exept one. Exlude one directory i.e. ls */*.png works fine. ls (^one)*/*.png ...
0
votes
4answers
119 views

Foreach loop for ls output

I am trying to process some files in directory using foreach loop for ls output: IFS=$'\n' for i in $(ls -1Atu); do echo "$i" done At first time i thought it works, but when i created file ...
2
votes
2answers
187 views

ls pattern matching

I know that [] is working in ls pattern matching: $ ls foo.c foo.h $ ls foo.[ch] foo.c foo.h but I cannot find where this is documented. I would like to know the syntax that would match these: ...
2
votes
1answer
49 views

Prevent glob expansion in foo=“*”; echo $foo [duplicate]

In Bash, when I do: foo="*" echo $foo It expands * to the contents of the current folder. How do I make sure it just prints a literal *? The same, by the way, happens with a regular echo "$foo", ...
1
vote
2answers
104 views

How can I select 3 character files in Bash?

I know that a question mark is considered a special character and it has special meaning. Question mark represents a single character that can be any type. In my practice lesson we have an example : ...
3
votes
1answer
43 views

Shell glob - substitute file path arg with file's contents

In curl command, there is --data option, which substitutes the file contents when the option value is prefixed by @ symbol like, curl -X POST --data @abc.json hostaddr.com abc.json file contents ...
0
votes
2answers
36 views

is it possible to open files in subdirectories with less?

I sometimes use less to quickly page through a small collection of files using something like less brscan/*/* and then I use :n to cycle through the files If I have a folder/s e.g. brscan/ ├── ...
4
votes
2answers
81 views

Expand wild cards in command before executing it

Suppose I want to type something like this: rm build/* tmp/* I am about to run it but I want to expand the wildcards before executing so I can verify what is about to happen. How can I do this? ...
28
votes
2answers
836 views

find(1): how is the star wildcard implemented for it to fail on some filenames?

In a file system where filenames are in UTF-8, I have a file with a faulty name; it is displayed as: D�sinstaller, actual name according to zsh: D$'\351'sinstaller, Latin1 for Désinstaller, itself a ...
4
votes
1answer
234 views

Why does `du -sh *` complain about invalid options?

I've searched my best through Google, but for the life of me I can't figure out what to use instead of * (asterisk) after a recent update (even Wikipedia seems to think du -sh * and du -sh * should ...
4
votes
2answers
124 views

brace expansion and * expansion

Assume in the working directory, there is only one djvu file. I would like to backup the file into a file with file name having extra .bk at the end. cp *.djvu{,.bk} copies the djvu file into a file ...
21
votes
7answers
1k views

`command .*` acts on the parent directory

Someone of our team wanted to recursively change the user permissions on all hidden directories in a users home directory. To do so he executed the following command: cd /home/username chown -R ...
3
votes
2answers
54 views

Shell globbing without matching files

I frequently make use of shell file name globbing to do things like operate on all of /dev/sda, /dev/sdb, /dev/sdc, etc by doing /dev/sd[a-f], however, this relies on there being files on disk that ...
1
vote
4answers
189 views

How do I suppress error messages from cp?

I am currently looking ways to suppress error command in Linux, in particular, the command cp. I do: root@ubuntu:~$ cp /srv/ftp/201*/wha*/*.jj ~/. cp: cannot stat `/srv/ftp/201*/wha*/*.jj': No ...
0
votes
1answer
41 views

Glob pattern argument for echo command

echo *.c in bash, treats the argument as a constant and prints *.c. How to force it to consider it as a glob pattern and print the list of files/folders ending with .c?
1
vote
1answer
68 views

Begin a glob with an exclude pattern

I am trying to tweak some completion. Suppose I have: $ ls bar.baz foo_bar.baz foo.bar If I want completion to match all files that don't end in baz: $ shopt|grep extglob extglob on $ ...
0
votes
1answer
32 views

Find a file that doesn't include specific characters

I want to find a specific file that doesn't start with a,k,G or Q and in which the third letter in the name is not a digit. I have tried many links, but found nothing regarding to this composite ...
4
votes
5answers
194 views

How can I use a wildcard to match just files, not directories?

I have a folder called home/homeLife I have a file called home1 home2 and home3 stored in /home I want to move all files that start with home* to home/homeLife/.. I typed mv home* /home/homeLife ...
1
vote
3answers
57 views

How to can I make Filename Sequencing with the help of Loops

my intention is to keep the code as simple as possible.Here there are 5 files namely A_1.CSV, A_2.CSV, A_3.CSV, A_4.CSV, A_5.CSV The below code retrieves the first row in a CSV file. Code : ...
1
vote
1answer
62 views

how to locate a name-not-specified file in bash? [closed]

I have a bash like this to easily upload a file to my server: FILE=../"$1"/1.txt scp 1.txt remoteserver #upload the file to a remote server. The $1 is for input directory and I have a lot of ...
0
votes
1answer
18 views

how to find the files in a directory with Prefix__date_030000_1.txt?

how to find the files in a directory with Prefix__date_030000_Suffix here Prefix is the Actual file name and format of the date is date +%Y%m%d and Suffix is the '.txt' and the 030000 number will ...
1
vote
0answers
75 views

What is the meaning of the string **/* when used with grep?

I came across this picture (below), obviously it is a pun or some kind of allusion incorporating command-line expressions. Frankly speaking I do not understand anything of it except for grep -n. ...
3
votes
3answers
411 views

How to match * with hidden files inside a directory

How to match the hidden files inside the given directories for example If I give the below command it's not giving the result of the hidden files, du -b maybehere*/* how to achieve this ...
6
votes
5answers
214 views

execute a command in $PATH matching a wildcard

I'd like to find and execute a command in the current $PATH matching this wildcard libreoffice?.? (eg. libreoffice4.0, libreoffice4.3, etc.) EDIT: if multiple matches are found, you can pick one ...
3
votes
1answer
88 views

How do you get the first file in each subdirectory matching a list of file extensions?

How do you get the first file in each subdirectory matching a list of file extensions? My goal is to run a program on just any one of the files in a series of subdirectories. For example, below ...
3
votes
1answer
88 views

Filename expansion from date ranges

Consider dates in the ISO 8601 format i.e. ‘YYYY-MM-DD’, e.g. 2015-01-28, and say we have a folder with files of the form: AAAA_<date>_BBBB I am looking for a glob pattern in zsh (or Bash) ...
3
votes
1answer
169 views

Triple dot wildcards

I have a very large directory structure of source code that is very difficult to work with. I would like to run a tool to transform it to a Maven like structure that works better for me. When I have ...