All Questions
14
questions
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 ...
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:
...
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 ...
-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 ...
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 ...
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 ...
4
votes
4
answers
3k
views
How to escape shell metacharacters automatically with `find` command?
I've got a bunch of XML files under a directory tree which I would like to move to corresponding folders with the same name within that same directory tree.
Here is sample structure (in shell):
...
3
votes
4
answers
4k
views
Bash: move files of specific pattern
I write a script that iterates over a set of zip files, extracts them and moves only files that match a specific filename pattern to another folder.
The script:
#!/bin/bash
ARCHIVE_FILEMASK="????-??...
10
votes
1
answer
11k
views
Bash substitution with variable defined from a glob pattern
The below example explains the issue. Why is the FILENAME printed correctly when echoed and perceived as a pattern when using substitution?
#!/bin/bash
FILEPATH_WITH_GLOB="/home/user/file_*"
...
4
votes
4
answers
12k
views
Passing wildcard * to a (bash?) script [duplicate]
I want to to remove all color codes which look like '@n', '@R' etc, from a moderately large size collection of text files.
So in a file called 'remove_cc', I wrote the following:
sed -ie 's/@r//g' $...
2
votes
2
answers
8k
views
Problems with basename in a loop
I am new at shell script programming and I'm trying to execute a software that reads a text and perform it's POS tagging. It requires an input and an output, as can be seen in the execute example:
$ ...
2
votes
3
answers
4k
views
Very strange behavior with grep and IFS
I'm having trouble using grep, the returned results are "n-empty", I mean without the 'n' character...
This is the script sample :
OLDIFS=$IFS
IFS="\\n"
i=$(grep -ril $1 *)
echo $i
IFS=$OLDIFS
I ...