0

What would be output if we type something like this in our terminal

/home/user/some character with *

e.g.

/home/renga/i*

I pass a variable (home/renga/i*) like this in my script, in run time the value was passed along with a file name instead of /home/renga/i*.

AdminBee
  • 22,803
Renga
  • 393

1 Answers1

4

Yes, * is called a "wildcard" and it's mostly used as a symbol to represent one or more characters.

Consider your example (with added command from me):

ls /home/renga/i*

where the /home/renga directory is like this

internal
inspiration
auth
unknown
liar
i*

Thus your command will give an output like this:

/home/renga/internal
/home/renga/inspiration
/home/renga/i*

If you want to access the i* directory or file, you need to add a backslash, \, in your command, so the command is something like this ls /home/renga/i\*, and the output will list the i* file or the content of the i* directory.

You can also use a quote to avoid matching filenames. So it is would be something like this:

ls /home/renga/"i*"

You can read more about wildcards here

Chris Down
  • 125,559
  • 25
  • 270
  • 266
hanysfa
  • 103
  • thx all..i just tried escaping the * as well as "*" ,both worked fine and thx for the explanation.. – Renga Oct 08 '20 at 07:01