Skip to main content

All 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_*....
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
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
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
-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
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
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
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): ...
kenorb's user avatar
  • 21.3k
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="????-??...
twenty7's user avatar
  • 87
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_*" ...
TheMeaningfulEngineer's user avatar
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' $...
roo's user avatar
  • 4,791
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: $ ...
Rafael's user avatar
  • 23
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 ...
Benj's user avatar
  • 123