25 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
2
answers
160
views
How to 7zip each file individually without the file extension included in the archive name?
I am trying to organize a large group of files for use with another program that can run them archived but only if they are named for example "My Document.7z" and not "My Document.txt....
3
votes
2
answers
150
views
Bash script: Matching extended glob pattern to a string array
Hello Amazing People,
I have been trying to achieve a goal of matching an extended glob pattern to a string array (file paths) and getting the list of file which matches to the pattern. Below is the ...
0
votes
1
answer
105
views
How to pass ext glob into bash script from sh and then expand it
I have script se.sh:
#!/bin/bash
files="1ドル"
shopt -s nullglob
shopt -s extglob
for f in a/path/to/all/files/${files}; do
echo "file process:${f}"
done
shopt -u nullglob
shopt -...
2
votes
2
answers
111
views
Bash extended glob pattern negation is not working in parameter substitution
Bash 3.2.57 (on macOS 12.6.8) extended glob pattern negation is not working in parameter substitution:
$ shopt -s extglob
$ s=abc
$ echo ${s##!(a)*}
I expected the last command to output abc, but it ...
0
votes
1
answer
93
views
How bash inverse pattern matching works internally in extglob?
Below files are present in current directory.
-rw-r--r-- 1 kazama kazama 0 Feb 16 08:50 london_july_2001_001.jpeg
-rw-r--r-- 1 kazama kazama 0 Feb 16 08:50 london_march_2004_002.png
-rw-r--r-- 1 ...
3
votes
1
answer
7k
views
How to remove all files except the ones that matches a pattern along several number of directories
lets say I have a my_dirs/ directory, insdie that directory I have several parallel subdirectories which has several files and I want to delete all of them except the ones that have the substring '....
2
votes
1
answer
202
views
Negate in bash extended globs does not work
I am trying to list some selective files but want to exclude atop_20210428, but the following extended glob atop_20210@(3|4)*[0-4]*!(8)* does not exclude the file atop_20210428, what is the correction ...
1
vote
1
answer
392
views
bash extglob pattern matching breaks when enclosed in a function [duplicate]
This works
shopt -s extglob
find /usr/!(^*|@*) -maxdepth 0 -cmin +1 -exec echo {} \;
shopt -u extglob
This returns an error
syntax error near unexpected token `('
function test {
shopt -s extglob
...
1
vote
1
answer
93
views
Pattern works in interactive shell but not in script
In my interactive shell I can store a pattern in a variable
$ targets="?(pcm52|pcm61)"
$ ls -l config/devdesc.$targets
-rw-r--r-- 1 kfa kfa 113 Dec 16 13:43 config/devdesc.pcm52
-rw-r--r-- 1 ...
0
votes
1
answer
106
views
in bash how to put extglobed file names into array?
I knew I can do arr=(*.log) to get all *.log files into arr. But when I try extglob with more complex pattern it seems fail:
$ shopt -s nullglob extglob; x=([a-z][0-9].+([0-9]).*.gz); echo "${x}&...
Wang's user avatar
- 8,446
0
votes
1
answer
337
views
Negative pattern match for lftp remove
In a GitHub action, I'd like to remove the old bundle files from the FTP server after deploying the new bundle. To achieve this, I thought to
Deploy new bundle
Parse the hashes of (main-\*.js, ...
1
vote
0
answers
124
views
bash script doesn't act like shell
Here is my script:
#!/bin/bash
x="aabcaa"
y=${x##*(a)}
echo $y
It outputs aabcaa when I expect bcaa.
When I try the same commands on a bash shell (got with bash command from zsh shell), ...
16
votes
3
answers
3k
views
Pattern match does not work in bash script
Using the pattern match !("file1") does not work within a bash script but will work on the command line.
For example:
ls !("file1"|"file2")
This will list all files in directory except file1 and ...
0
votes
1
answer
78
views
Bash extended globbing bug?
There are three files in a directory:
ab2 ab23 ab3
When I execute:
ls ab+(2|3)
It displays:
ab2 ab23 ab3
instead of ab2 and ab3 only.
Any ideas why it is like that? Is it a bug?
-1
votes
1
answer
290
views
Bash script to copy folder and contents without one file
I'm trying to copy a directories contents without one file. The problem i'm having is that the file is a few folders nested and the extglob operator fails to match.
Assume the following folder ...