Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why cant i expand filenames in bash 1

Status
Not open for further replies.

grazinggoat2

Systems Engineer
Jun 25, 2019
6
US
Hello,

why cant i get this to work in my bash script? I have multiple files with the same name but different file extension.
example
batch.prd
batch.uat
batch.dev

_filename="repo/batch"

seek=$(grep "job name_A" "$_filename*" |sort -u)

I've tried "$_filename.*" and "$_filename./*" but bash will not expand the filenames for the grep to do a once over and i prefer not writing a loop to go thru each file. Any thoughts as I'm just not sure how to expand a filename with extensions

Thanks in advance!
 
Hi

man bash | QUOTING said:
Enclosing characters in double quotes preserves the literal value of all characters within the quotes, with the exception of $, `, \, and, when history expansion is enabled, !.
So your asterisk ( * ) enclosed in double quotes ( " ) is considered a literal asterisk character, without any special meaning. So just do not enclose it in double quotes.


Feherke.
feherke.github.io
 
Ahhh... I have to dig into the man pages more. This worked. thnx!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top