Tagged Questions

Globbing means matching files by name patterns containing wildcards.

learn more… | top users | synonyms (2)

2
votes
2answers
53 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
70 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
75 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: $ ...
-5
votes
2answers
771 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
378 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
134 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
174 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
74 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
99 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
358 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]
5
votes
3answers
606 views

Linux command to return all files that start with TEMP but do not end with double digits

What is the Linux command to return all files that start with TEMP but do not end with double digits? I think it should look something like this: ls -l TEMP*[!0-9][!0-9] but the results of my ...
3
votes
5answers
160 views

Look if a folder has some files of certain extention

Lets say I have a file structure: $ cd /home/Desktop $ ls -d */ Abc/ Qwe/ Zxc/ Rty/ $ Now I want to iterate through every directory and look if they have any .pdf files. Could some one please ...
5
votes
4answers
569 views

Check if a folder has a certain type of file present

How could I check if a file has a file of extension .java? So far I have: for javaFile in *.java ; do { echo "The file $javaFile has : " >> ~/Desktop/externalServers.txt ...
3
votes
2answers
56 views

Using a glob pattern as an argument to “which”

Is it possible to use the which command on a glob pattern to return multiple results? For example, I want to know the full path of all my latex commands. I can try: ...
1
vote
2answers
160 views

how to insert many similar records in mysql at a time?

we know that we can insert multiple records at a time using this query: INSERT INTO `TABLE1` (`First`,`Last`) VALUES ('name1','surname1'), ('name2','surname2'), ('name3','surname3'), ...
1
vote
2answers
205 views

Will a '*' (star) in globbing match only characters (i.e , a-z and 0-9)?

I havie a simple question here: does a * (star wildcard) match only characters (letters and numbers) in glob style? Or will it also match special characters? In bash, * matches everything, while in ...
2
votes
2answers
249 views

how to show total files size in a folder by filtering extension without showing each file size

du -hc *zip shows me total size of zip files in a folder, but it shows also every single file size of the folder. I only need total size. Is there way to show the total size of a folder without ...
0
votes
6answers
577 views

How to list files starting with “a” or “c” from /etc.

I tried ls /etc/[ac]* but it shows directories starting with a or c, and their entire contents, not the files starting with "a" or "c".
2
votes
1answer
80 views

Globbing fails in zsh, but works in bash

I have an alias in bash, that I'm trying to port over to zsh. I thought it may have been the alias itself, but now it seems it's just the globbing. grep -irl --exclude=\*.{log,class,fuegoclass,dat}* ...
2
votes
1answer
92 views

scp wildcard not working in zsh

I have switched over to zsh, and it is working fine. One strange thing, when I try to scp with a * wildcard, it does not work, and I have to drop into bash. The second command below works fine. Any ...
6
votes
2answers
799 views

Copying one file to multiple directories

I have a file that I want to copy to another 60 directories. The best way I can think of doing this is by making a bash script that has instructions to every folder like this: cp script.sh ...
2
votes
1answer
118 views

Move extension-less files with mv

I have a folder with images(png, bmp, jpg) and extension-less files. I cant figure out how to move only the extension-less files. They are all random numbered files.
5
votes
2answers
117 views

ls command: how to ignore case without globbing

I use the shopt -s nocaseglob command to ignore case, but it seems like it doesn't work if I use a string without glob. Just a question out of curiosity, is it possible to ignore case without ...
4
votes
1answer
54 views

Use rsync to just get a folder and its content with a pattern

I've looked all around the internet, looked in regexp sites and everything else, but I'm unable to write a rsync command to fetch what I want to. I need to mirror the FreeBSD release, but I don't ...
4
votes
4answers
2k views

How to exclude some files not matching certain extensions with grep?

I want to output all lines containing the word OK recursively from a directory. But there are a few extensions which I need to exclude from the result: *~ *.map *.js except *.debug.js I tried: ...
4
votes
2answers
585 views

Script to loop through folders with numeric names

I am working on a bash script to compress the images in my Wordpress folders. The wordpress folder structure is as follows: > wp-content/uploads/2014/01/filename.jpg > ...
1
vote
2answers
114 views

tar specific files based on a pattern

I got a lot of files with the following format: 2014_04_01_11.txt 2014_04_01_12.txt 2014_04_01_13.txt 2013_03_25_12.txt 2013_04_29_15.txt I would like to tar all theses files into an archive 20?? _ ...
2
votes
1answer
98 views

Specifying full range of printable ASCII characters in a glob pattern

I want to use a globbing pattern to match only printable (including space) ASCII characters 0x20 through to 0x7e. This is being used inside a super super.tab database. I've arrived at the pattern: ...
5
votes
1answer
4k views

Why is my find not recursive?

I am running the following command, but it is not performed recursively: find . -name *.java I know there are java files further down in the current directory but it is performing the find on the ...
16
votes
7answers
4k views

How do I copy multiple files by wildcard?

I have a folder with a number of files in it ABC.* (there are roughly 100 such files). I want to duplicate them all to new files with names starting with DEF.* So, I want ABC.Page1 ABC.Page2 ...
1
vote
3answers
395 views

Delete files with same name at the end of the file

Delete files with same name at the end of the file i have a lot of files in my folder and sub directories like ajax_hostel_room_master.php.php class_hostel_registration.php.php ...
3
votes
1answer
79 views

grepping with “shopt -s globstar extglob”

I have shopt -s globstar extglob in my ./bashrc. I'm searching for files that refer to string Foo in the following command: grep -Fwn Foo /**/src/**/*.@(h|cpp) Now I want to except all refers from ...
40
votes
2answers
3k views

Why does rm *(1)* remove all files in a directory?

I expected that: $ rm *(1)* would remove all files containing (1) in the name. I was wrong. It removed all files in the directory. Why?
26
votes
1answer
1k views

Why does my regular expression work in X but not in Y?

I wrote a regular expression which works well in a certain program (grep, sed, awk, perl, python, ruby, ksh, bash, zsh, find, emacs, vi, vim, gedit, …). But when I use it in a different program (or on ...
4
votes
2answers
720 views

bash globstar matching

I have this directory structure: ~/tmp/globstar ɀ find dir -type f dir/file.ext dir/subdir1/file.ext dir/subdir2/file.ext and, with the globstar option enabled in Bash, I can say: ~/tmp/globstar ...
2
votes
1answer
66 views

Can I use variables inside {} expansion without `eval`?

Can I use variables inside {} expansion without appealing to eval? If so, how? This doesn't work: $ touch 1.foo 1.bar $ ls 1.{foo,bar} 1.bar 1.foo $ extensions=foo,bar $ ls 1.{$extensions} ls: ...
6
votes
2answers
2k views

Remove unknown unicode character from textfiles - sed, other bash/shell methods

I need to search and replace all occurences of an unknown character in some files having the same name. Opening such files with vi, I read <91> code for that character. Opening them with nano, I ...
4
votes
1answer
147 views

Why does grep treat '[D]ebug' string differently?

I've created simple text file named "T" to test the unusual behavior of grep: 1 Debug 2 debug 3 determined 4 Determined Tried different syntax: $ grep De T 1 Debug ...
2
votes
2answers
400 views

delete directory with special character in filename

I have these tricky directories that I can't figure out how to delete. If I run ls -ld * I get… drwxrwxr-x 7 user1 taskfmri 2048 Jan 22 15:26 857263 drwxrwx--- 4 user2 ...
11
votes
2answers
2k views

What is the difference between “du -sh *” and “du -sh ./*”?

The title says it all. What's the difference between those 2 commands? NOTE: I'm more interested in the * and ./* part.
3
votes
3answers
75 views

Full path in glob in Zsh

Say I run the following on /some/path: for x in foo/*; do print $x done Are there any parameters I can use to tell Zsh to print, not just the filename, but the full absolute path to $x? (without ...
1
vote
2answers
65 views

Is there an equivalent to bash's “nocaseglob” in ksh?

I would like to do what is mentioned in How to match case insensitive patterns with ls? except for ksh. Is it possible to do it without any pain(regex)?
2
votes
2answers
293 views

Bash's declare -p HISTIGNORE brings bash to a halt! Why?

Executing the following code in GNU bash, Version 4.2.45(1)-release (x86_64-redhat-linux-gnu), Fedora 19 ... shopt -s extglob export ...
2
votes
1answer
84 views

Does * match hidden files in tar even with dotglob unset?

I was under the impression that the * glob does not match dot-prefixed files unless you manually enable such functionality (through dotglob, or your shell's equivalent). Yet if I have a directory a ...
3
votes
1answer
48 views

**/ not working with a mounted volume

I'm trying to recursively extract a set of .jpgs from a mounted volume using SMB1, to a folder on my computer. Here's what I've got: cp -a **/97*.jpg /Users/.../All_Covers This works as long as my ...
12
votes
2answers
700 views

Shell filename pattern that expands to dot files but not to `..`?

Recently I had a little mishap caused by a shell pattern that expanded in an unexpected way. I wanted to change the owner of a bunch of dot files in the /root directory, so I did chown -R root .* ...
1
vote
2answers
1k views

Differing outputs of the commands “ls .*” and “ls *.”

The command ls .* when run gives as output the following : All the files in the current directory starting with a . (hidden files) All the files in the hidden directories present in the ...
3
votes
3answers
2k views

How to delete 2 months back files in unix

Say I have below log files, AA_XX_20130719185428.log exec_xxx_cpb_20130712182453.log 13122013121327_AR_INC_DOBC_1.dprf.log 24122013_masterscript.LOG Date part contains both date and time. I want ...
2
votes
1answer
132 views

SFTP chroot jail/access based on wildcard

I want to give a list of people SFTP access to /webdocs/ABC* where they will read-write access to only directories that match this wildcard. How do I do this? Can I create a chroot jaill or some ...
6
votes
2answers
577 views

How does GLOBIGNORE work?

According to bash's manual page: GLOBIGNORE A colon-separated list of patterns defining the set of filenames to be ignored by pathname expansion. If a filename matched by a ...