All Questions
64
questions
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 ...
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 "$...
-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 ...
-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 ...
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 ...
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 ...
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
...
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 ...
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 ...
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 ...
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 $...
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 ...
-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 $...
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 ...
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 ...