Skip to main content

All Questions

Tagged with
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 ...
Amarakon's user avatar
  • 333
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) ]...
kjo's user avatar
  • 15.6k
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....
jxhyc's user avatar
  • 181
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 ...
Tim's user avatar
  • 103k
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 ...
StuartM's user avatar
  • 123
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 ...
Michael Kolber's user avatar
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_*....
ganq's user avatar
  • 11
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 ...
Xerz's user avatar
  • 131
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 ...
unfa's user avatar
  • 1,745
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'...
Ken Y-N's user avatar
  • 253
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 ...
Nicolás Alarcón Rapela's user avatar
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: ...
Smashgen's user avatar
  • 393
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 ...
lonix's user avatar
  • 1,793
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, ...
Weijun Zhou's user avatar
  • 3,418
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 ...
kelvin .C's user avatar
1 vote
1 answer
325 views

grep not working when I enclose the directory in double quotes

When I do something like this: grep "hello" /home/paul/* It works. But when I do something like this: grep "hello" "/home/paul/*" grep display the error: grep: /home/paul/*: No such file or ...
paul's user avatar
  • 495
2 votes
2 answers
10k views

How to use the ls ? option in a bash variable?

I want to use the ls ? option in a Bash variable. How do I get the script to do the same thing as ls -lt foobar_??????.log ? $ cat foobar_ls.sh #!/bin/bash FOOBAR_LIST="foobar_??????.log" ls -lt "$...
zundarz's user avatar
  • 363
-2 votes
2 answers
625 views

why command not working properly when wildcard is detected

segment of code from shell script fname=$(sed 's/(.*//' <<< $p | awk '{ print $NF }') if [[ $fname == *['!'@#\$%^\&*()_+]* ]] then flag1=0 fi where $p is one line from a text ...
user143252's user avatar
-4 votes
1 answer
325 views

Folder exclusion formatting issue

I'm trying to create make targets for flawfinder and cppcheck that will recursively search the current directory, but ignore directories named "Test". However, I have run into some issues with ...
Aidan Grimshaw's user avatar
0 votes
2 answers
672 views

What is the difference between '*.txt' and *.txt?

I was completing the git tutorial found here: https://try.github.io/levels/1/challenges/7 And it said that I had to put single quotes around *.txt. I had not seen this before when using linux but ...
Fortune's user avatar
  • 103
1 vote
1 answer
111 views

Shell expansion not happening

Why are these two commands equivalent (or so it seems based on the results I get back)? I figured the first command wouldn't work because the * would be treated as the glob operator but instead it got ...
11th Hour Worker's user avatar
0 votes
1 answer
276 views

ls -l seems to give one concatenation of the filenames found in a directory

I want to write a shellscript to convert all .ogg files in a directory to .mp3 files. The filenames contain spaces, so I use a lot of double quotes in the sequenco of commands. The command I use is ...
Jogchum's user avatar
0 votes
2 answers
108 views

Loop space directory name [duplicate]

I have a CT.txt with below input data. CT.txt: test testing test 1 And with below script: #!/bin/bash for CITY in $(cat /home/user/CT.txt) do FILES=/mnt/dir1/dir2/$CITY/* echo $FILES Giving me ...
Amrut Nadgiri's user avatar
0 votes
2 answers
83 views

In what way does quoting parameters to `find` matter? [duplicate]

When looking for txt files, I run this command: find . -name "*.txt" -print This gives me a list of all the text files beneath current directory. However, find . -name *.txt -print gives me the ...
Abdi's user avatar
  • 13
5 votes
1 answer
235 views

Why file glob expansion is not suppressed

I have the following script my.sh: echo $@ Now I want to see file glob expansion, so I do like this and it works OK: $ bash my.sh * $ f1 f2 my.sh Now, I've tried suppress expansion using ...
Max Koretskyi's user avatar
7 votes
2 answers
6k views

OpenSSH: Prevent globbing on SSH_ORIGINAL_COMMAND

I have the following setup where I use an OpenSSH server to remotely start a certain command using ssh. My authorized_keys file has the following entry: command="/path/to/script.sh $...
phk's user avatar
  • 5,983
32 votes
5 answers
53k views

How to make bash glob a string variable?

System Info OS: OS X bash: GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16) Background I want time machine to exclude a set of directories and files from all my git/nodejs project. My ...
John Siu's user avatar
  • 4,785
-1 votes
1 answer
331 views

bash is changing my tr statement

Running a bash (4.1.2) script with the trace options -v and -x the following code for Option in "$@"; do OptName=$(echo $Option | tr [:lower:] [:upper:]) results in + for Option in '"$@"' echo $...
kenneth kahn's user avatar
0 votes
2 answers
3k views

Wildcard not working in quotes

The script is supposed to loop over subdirectories and match all the filenames (FLA.*Image.*file.jpg and FLA.*Image.jpg) in subdirectories and process it. It also create output folder inside the ...
Tom's user avatar
  • 1
5 votes
1 answer
8k views

Why is find not listing matching files when preceded by an asterisk(*)? [duplicate]

On Ubuntu 14.04, 64 bit, I have set /lib/modules/4.2.0-27-generic/kernel/drivers to be my current directory. I intend to search all files having net present as a sub-string. If I search with a regex ...
sherlock's user avatar
  • 646

15 30 50 per page