V
V
Vadim2019-06-20 17:53:20
bash
Vadim, 2019-06-20 17:53:20

Why is the variable expanded with quotes or trying to transfer files right away?

Hello
Script:

#!/bin/bash

filex="*.pdf"
folderp="/path/to/folder"

When I added the command , it doesn't find anything, since the second variable is expanded with single quotes '.pdf' Naturally, I don't have such a file. I can't pass the second parameter without quotes. Design: Works as expected Regards, Vadim
find "$folderp" -type f -name "$filex"
find "$folderp" -type f -name "*.pdf"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2019-06-20
@Viji

In fact, your design should work and it works quite correctly for me.
Can you give an example of the output and make sure that at least one pdf file is in the right directory?
Are you sure you have *.pdf files in the specified path? Maybe there file.PDF ?

J
jcmvbkbc, 2019-06-20
@jcmvbkbc

it doesn't find anything because the second variable is expanded with single quotes '.pdf'

And I have everything I need to find your script. You can add -xto #!/bin/bashso that the shell writes what it is going to execute in order to understand what's going on. I suspect some funny options in .bashrc/.bash_profile

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question