Globbing means matching files by name patterns containing wildcards.

learn more… | top users | synonyms (2)

1
vote
2answers
72 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
30 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
30 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
72 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
711 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 ...
3
votes
1answer
112 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
102 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
44 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
88 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
27 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
56 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
26 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
160 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
42 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
56 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
16 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
63 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
206 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
137 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
60 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
63 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
98 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 ...
-1
votes
4answers
250 views

How do I list files ending in txt only on Unix?

I have a directory with nine files in it. 1 ending in .bat 2 ending in .bak 4 ending in .txt 2 ending in .xtxt My question is, how do i list only the files ending in txt, but without the period. ...
1
vote
2answers
56 views

List the files of another format while finding a certain name pattern

I had wanted to edit the txt files of videoA and videoB only if the movs files names contains the namespace -test For eg. videoDir |-videoA |- videoA_v001_test.mov |- ...
10
votes
5answers
856 views

How to get the last N files in a directory?

I have many files that are ordered by file name in a directory. I wish to copy the final N (say, N=4) files to my home directory. How should I do it? cp ./<the final 4 files> ~/
1
vote
1answer
15 views

Getting globbing to work with `locate`?

I'm on Ubuntu 11.04, where I have: $ locate --version mlocate 0.23.1 [...] The man locate page says: If --regex is not specified, PATTERNs can contain globbing characters. If any PATTERN ...
2
votes
2answers
36 views

“dpkg -l” receives shell wildcard character?

In a bash shell where I have globbing enabled if I execute ls -l *ou*, then shell should pass out.dot and out.png as arguments to ls, i.e. ls never sees the * character. However, looks like in case of ...
4
votes
2answers
732 views

Why does ls display a non-existing file?

I want to list all the files whose name begins with uppercase: [root@localhost /]# ls /usr/bin/[[:upper:]]* /usr/bin/AtoB /usr/bin/GenIssuerAltNameExt /usr/bin/PKCS12Export ...
1
vote
0answers
26 views

optimisation of bash globs

Looking for a guide to optimising regexp matches in bash. I have a script that loops over a very long list of URLs looking for patterns. Currently it looks a little like the fragment below. Is there ...
2
votes
2answers
43 views

Bash globs as non-file arguments. Example: apt-get remove pkg-*

I know * and other glob patterns are transformed into words by pathname expansion, based on the current working directory. Hovever, some commands seem to use them for non file arguments. For example, ...
4
votes
2answers
41 views

Meaning of “[--0]” in a glob pattern

I am a Linux/Unix newbie. I was reading about "Glob" and "Globbing Pathnames", and I found this strange (to me) part in man pages: "[--0]" matches the three characters '-', '.', '0', since '/' ...
0
votes
3answers
87 views

Number of files in a directory starting with specific text

How to get count of files in a directory starting with specific text like dataxxx.csv
-1
votes
2answers
179 views

delete files having a certain pattern in their names

I want to delete all files that have two numbers and a dot in beginning of their names for example: 01. abc 02. xyz
4
votes
2answers
70 views

Unzip source arguments

To copy a bunch of zip files from one location to another: $ cp *.zip destination/ To unzip a bunch of zip files to a directory: $ unzip \*.zip -d destination/ man unzip says: The backslash ...
1
vote
3answers
501 views

List files that do not begin with a specific prefix

I need to list only the files in a directory that do NOT begin with qc_dl, qc_dt or qd_df, but that also DO end in .sas. I can list the files that do not begin with "qc_dl" as such: ls -I "qc_dl*" ...
2
votes
2answers
82 views

order for listing files

If I have a list of files under a directory ullman-000.pbm ullman-001.pbm ... ullman-098.pbm ullman-099.pbm ullman-1000.pbm ullman-1001.pbm ullman-1002.pbm ullman-1003.pbm ullman-1004.pbm ...
1
vote
1answer
49 views

Shell glob expansion after loop variable substitution

How can the following be changed example so that it does glob expansion after loop variable substitution? for i in a b c do echo $i/*.txt done UPDATE: This normally does work, however set -f ...
2
votes
1answer
73 views

Find Command: File Path vs -name Argument

I'm currently building a script to handle some files in a directory. In the first example, I use the find command and pass a directory in as the argument. In the second I instead use the -name switch ...
0
votes
1answer
73 views

defining rename command scope; replace word; replace entire file name; wildcards

Im looking to use the rename command to edit file names. More specifically, Im trying to isolate specific pieces to change, or in some cases, the whole name. For example: Lets say I have three ...
2
votes
2answers
191 views

Bash extended globbing

I'm unable to show JUST ONE file from the output of ls using bash extended globbing. From info bash If the `extglob' shell option is enabled using the `shopt' builtin, several extended pattern ...
2
votes
3answers
148 views

Find files that end with number

Im trying to make some backup script as the log files get bigger and bigger. What i have is coping the current file, (for example secure file in /var/log/) and remove the content from that file. But ...
2
votes
2answers
56 views

Tar a list of files which don't all exist

I'm running a command from a script like tar -c -f ar.tar a b c d where b, c, and d may not exist, and may be directories. The solutions that I've come up with are piping the output of ls -d to ...
3
votes
4answers
228 views

what is the difference between `find .` and /home/user/* as an input to for command

What is the difference between find . and /home/user/* as an input to for command.? For example: for var in $(find .) do echo "$var" done or for var in /home/user/* do echo "$var" done In the ...
5
votes
3answers
449 views

How to view last 5 lines from last created/modified file?

Every day I have to take backup and update the status to support teams at particular time for which I need to check last 5 lines of last created/modified *.aff file in a directory and update them. ...
4
votes
2answers
669 views

How to show only total file size of particular extension by `du` command

I have a hundreds of pdf files and html files in a directory. And I want to know total size of pdf files. By command du -ch /var/foo I can see total file size but I only need last line, the total ...
0
votes
4answers
402 views

keep the last file of every month and delete the rest

I have files like below. I want to keep SEP 30, OCT 30....files and delete the rest. Can you please help me with any script? -rw-r--r-- 1 nbswmcm advboprd 13463761 Sep 2 01:19 ...
0
votes
2answers
49 views

can I use logical operators to remove all files that matches with one and/or other pattern in a single line?

I want to remove .txt or .csv files in a single line. What I have in my directory tachomi$ ls file1.csv file1.sql file1.txt file2.csv file2.sql file2.txt I only want .sql files so I want to ...
5
votes
5answers
349 views

How can I programatically tell if a filename matches a shell glob pattern?

I would like to tell if a string $string would be matched by a glob pattern $pattern. $string may or may not be the name of an existing file. How can I do this? Assume the following formats for my ...
2
votes
1answer
48 views

How can I use `find` with `-pattern` and also restrict depth?

This is as far as I've gotten: find . -path \*/pages/*/index.css Which will find: ./lib/pages/home/index.css ./lib/pages/home/lib/header/index.css What I really want is to only find: ...