Tagged Questions
3
votes
4answers
62 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 ...
1
vote
2answers
53 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
71 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 ...
3
votes
3answers
341 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 ...
3
votes
3answers
222 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 ...
11
votes
2answers
216 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
63 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 ...
2
votes
2answers
250 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 ...
3
votes
1answer
366 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? ...
6
votes
3answers
3k 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.
4
votes
2answers
476 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 ...
1
vote
2answers
145 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 ...
3
votes
2answers
480 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 ...
3
votes
1answer
268 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
249 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
448 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 ...