All Questions
64
questions
0
votes
1
answer
41
views
How Can I Interpret Quoted Wildcards
I am writing a shell script and I need to interpret quoted wildcards.
"R Programming*"
I do not want the * asterisk to be taken literally.
I want it to be interpreted as a wildcard.
"R ...
2
votes
2
answers
133
views
Test fails (correctly) on command line, but succeeds (incorrectly) in script
For the sake of this question, assume that the glob /a/b/c/* produces no matches.
This means that the following test should fail (in other words, it should produce a non-zero $?):
[[ -n /a/b/c/*(#qN) ]...
1
vote
1
answer
2k
views
grep: use square brackets to match specific characters
So I am experimenting with the power of grep using this resources
The problem I am currently encountering is that it doesn't seem to work as I intended. so I have an demo.txt file that contains foo....
2
votes
1
answer
1k
views
How to work around wildcard inside double quotes? [duplicate]
In bash, the file globbing * doesn't work inside double quotes, but my filename contains whitespace, so I need to double quote filename before passing it to a shell script. How can I do that?
For ...
2
votes
1
answer
1k
views
Unable to run npm install with version specification
I am trying to run a simple npm install with zsh terminal.
npm install --save-dev @typescript-eslint/eslint-plugin@^4.0.0
zsh: no matches found: @typescript-eslint/eslint-plugin@^4.0.0
It appears ...
2
votes
3
answers
317
views
How to double quote a wildcard pattern of files?
I've seen a bunch of similar questions to this one but none exactly the same.
I have a directory of files which I want to pass in as a single, double-quoted argument to a command, using wildcard ...
1
vote
1
answer
287
views
UNIX KSH - Using double quotes or no quotes when assigning strings with wildcard to a variable?
I am new to UNIX and currently working on a shell script where I will be receiving files with names such as abc_123_date.zip so the file names will be abc_123_12312005. Instead of hardcoding abc_123_*....
3
votes
2
answers
954
views
Globbing within a parameter expansion
I'm trying to select the files within a set of directories passed as arguments with the following:
${@/%/*}
However, this is not ideal, since paths with spaces will break, and quoting the parameter ...
2
votes
1
answer
7k
views
Cannot rm or cp files with a wildcard in name [duplicate]
I have a line like this in my script:
rm "$TEMP_DIR/*.txt"
It fails with this output:
rm: cannot remove 'temp/*.txt': No such file or directory
I don't understand why doesn't that work. What am I ...
0
votes
0
answers
16
views
How to append a "/*" to the end of a variable with spaces and glob it? [duplicate]
If I have a directory wibble, the following command does what I want:
WIBBLE=wibble
wc $WIBBLE/*
If I have a directory foo bar, the following command does what I want:
wc foo\ bar/*
But this doesn'...
2
votes
1
answer
788
views
Loop that lists folders with spaces
Approach
I have a directory with named folders, randomly, with blank spaces and periods.
I created a small loop (in a script) with the intention of renaming these folders.
On the basis that these ...
10
votes
1
answer
17k
views
Using a variable as a case condition in zsh
My question is the zsh equivalent of the question asked here: How can I use a variable as a case condition? I would like to use a variable for the condition of a case statement in zsh. For example:
...
10
votes
2
answers
9k
views
ls with a wildcard
This works from the terminal:
ls /dev/sda*
I want it in a bash script, using a variable. I tried:
device="a"
ls "/dev/sd"$device"*"
But I get the error: ls: cannot access '/dev/sda*': No such file ...
16
votes
2
answers
5k
views
How are double quotation marks in bash matched (paired)?
I am using GNU bash 4.3.48. Consider the following two commands that only differ by a single dollar sign.
Command 1:
echo "(echo " * ")"
Command 2:
echo "$(echo " * ")"
The output of them are, ...
0
votes
3
answers
1k
views
Can’t echo variable value=* in script [duplicate]
Content of myfile:
123
**1
**
Script that attempts to display each word:
for i in $(cat $myfile)
do
echo "$i"
done
the result is when echo *, it lists the files in my current ...