2
votes
1answer
25 views

search files using group permission

If i need to search files using group permission I use the following command echo **/*(AIE) where AIE stand for read/write/execute. For owner and group permissions the qualifier used are rwx and ...
3
votes
2answers
59 views

Disable glob qualifiers in zsh

Is there a way to disable glob qualifiers with zsh? It seems like a useful feature, but it gets in the way of normal parentheses. I use ag to search files, and ag mymethod(param) causes zsh to ...
2
votes
2answers
48 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 ...
2
votes
1answer
65 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
61 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 ...
3
votes
3answers
69 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 ...
3
votes
4answers
1k views

Searching a pattern in file names with number

I have a large number of files in a folder each with the date as the filename. For example 20130101 20130102 20130103 . . . 20130131 similarly for other months 20130201 to 20130230, the pattern is ...
6
votes
3answers
501 views

Remove all but one ( or more ) kind of filetype

I've been trying to find a command to remove all files in a folder but not a kind of filetype. But I seems to not have any luck. What I've tried so far : set extended_glob rm !(*.dmg) # this returns ...
3
votes
2answers
263 views

List all dotfiles current directory using zsh

How can I list all dotfiles in a directory using zsh.?
4
votes
2answers
189 views

Force Bash 4 'globstar' option to ignore symlinks

Bash 4 has a fantastic option called 'globstar' that emulates (i.e. was stolen from) zsh's ** syntax for globbing across multiple directories. However, it's somewhat crippled (for my usage, at least) ...
3
votes
4answers
1k views

cp hidden files with glob patterns

Situation : $ mkdir foo && touch foo/.test $ cp foo/* . zsh: no matches found: test/* (or bash : cp: cannot stat ‘test/*’: No such file or directory) I have a directory full of hidden ...
3
votes
1answer
150 views

How to use parameter substitution in glob pattern (zsh)

I want to process a bunch of files ending in some suffixes, so I wrote the following zsh script but it did not work. EXT=(.jpg .png .gif) EXT=${(j.|.)EXT} # EXT becomes '.jpg|.png|.gif' for f in ...
5
votes
2answers
181 views

Passing glob expressions to functions/scripts

The following script is supposed to concatenate multiple csv files in a path specified in the first argument into a single csv file specified in the second argument #!/bin/zsh set -x set -v ...
3
votes
4answers
180 views

Expansion with numbers in human readable format

So, I want to play some MP3s in a console player that takes file names as inputs. I have the following files, as given by ls -1 * where * get expanded by my shell (zsh): 1 - Main title.mp3 10 - End ...
5
votes
2answers
180 views

Modifying zsh globbing patterns to use with cp

I'm trying to write a script to copy files recursively from a particular folder except files A.extn, B/*.extn and C/* where B and C are directories and extn is just some generic extension. This is ...
3
votes
2answers
1k views

Excluding a directory name in a zsh recursive glob

I'm running zsh on Linux under setopt extended_glob ksh_glob glob_dots. I'm looking for something easy to type on the command line, with no portability requirements. I'm looking at a source code tree, ...
1
vote
2answers
126 views

How to get “current glob” in zsh

I want to do something like: $ convert [a,b,c,d,e].png -resize 50% <current_match>_half.png How can I do this? Is there some variable that stores the current match? I couldn't find anything in ...
4
votes
3answers
2k views

Using OR patterns in shell wildcards

Contents of my dir are $ ls -lrt total 0 -rw-r--r-- 1 user1 admin 19 Oct 8 12:31 night.txt -rw-r--r-- 1 user1 admin 19 Oct 8 12:31 noon.txt -rw-r--r-- 1 user1 admin 38 Oct 8 12:31 day.txt I ...
0
votes
1answer
870 views

Asking ls to only list files in a path that match a specific glob/regex

In Zsh: Is there a way to use ls to only list files and folders in the current directory that match a specific globbing or regex pattern? For example, say I have multiple files that start with the ...
3
votes
3answers
593 views

Fastest way to open all files in a directory with multiple file extensions on commandline

If I want to open all mp4 files in a directory, I can simply do something like totem *.mp4. But how can I open all mp4 and all flv files in that directory with one command. I.e. I want to do something ...
13
votes
2answers
363 views

Can I make `rm` interactive only when using globbing? (in either bash or zsh or both)

Whenever I rm multiple items at once with shell globbing and there's even the slightest possibility that the pattern expands to more than I expect it to, I always try to remember to add -i, but (of ...
1
vote
1answer
82 views

List all the matched files starting from an index

In zsh, there is the [m,n] glob qualifier which works as follows: [beg[,end]] specifies which of the matched filenames should be included in the returned list. The syntax is the same as for ...
3
votes
2answers
1k views

zsh: excluding files from a pattern

Say I have the following files: |-- bar `-- foo |-- type_A_1 |-- type_A_2 |-- type_B_1 |-- type_B_2 |-- type_B_xx |-- type_B_xx `-- something_else I thought the ...
4
votes
1answer
767 views

How do I filter a glob in zsh

Basically I can use a glob in zsh to a list. Often, it turns out, I would like to filter that list, grep'ishly I'm wondering though, if I need to do that. Does zsh have a method to filter a list? ...
7
votes
4answers
8k views

How do I reverse a for loop?

How do I properly do a for loop in reverse order? for f in /var/logs/foo*.log; do bar "$f" done I need a solution that doesn't break for funky characters in the file names.
6
votes
2answers
997 views

ZSH: Recursive globbing with .directories

I thought the glob pattern: **/(*|.*) would represent every folder and file starting with dot (.) or not, but it skips directories in the current directory that start with .. What is the glob ...
8
votes
4answers
1k views

How to silently get an empty string from a glob pattern with no matches

Say I have a folder with three files: foo1 foo2 bar 1. If I run list_of_files=$(print foo*) echo $list_of_files I get: foo1 foo2 2. If I run list_of_files=$(print bar*) echo $list_of_files ...
1
vote
2answers
224 views

Generate a list of files from a file containing a series of globbing patterns

I am looking for a way to build a list of files by parsing a file that contains a sequence of zsh globbing patterns. The final goal is to pass this list of files to hg add in mercurial. For those ...
6
votes
2answers
2k views

Multidigit ranges of files in lexicographical order in zsh

I would like to specify a range of files (in lexicographical order) with two integers (e.g. 2 to 57) in zsh by globbing. For example: "pick the files 2 to 57 in lexicographical order under the path ...
4
votes
1answer
458 views

ZSH: Globbing the first N files under a path in lexicographic order

I was wondering if there is a way to specify the first N files under a given a directory in zsh. I am interested in solutions for recursive enumeration (i.e. any file recursively below a path is ...
6
votes
1answer
328 views

Can I have my shell history record how wildcards expanded?

If I run: $ ls * foo bar buzz $ history | tail -1 ls * You can see that in my shell history it remembers that I ran ls * rather than ls foo bar buzz. Ideally, I'd like to record both in separate ...
3
votes
1answer
688 views

scp, globbing, and different shells

The other day at work I tried doing scp remotehost:~/*.txt . and I received an error about the *, *.txt file not found sorry, not at work and I forget the exact error on my workstation I run zsh ...