1

I recently saw a script in which below find command was used:

find "$@" -type f -name "*.iso"

What does "$@" mean here?

Prvt_Yadav
  • 5,882
A.K
  • 55

1 Answers1

6

"$@" expands to all arguments passed to the shell. It has nothing to do with find specifically.

https://linux.die.net/man/1/bash

@

Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, each parameter expands to a separate word. That is, "$@" is equivalent to "$1" "$2" ... If the double-quoted expansion occurs within a word, the expansion of the first parameter is joined with the beginning part of the original word, and the expansion of the last parameter is joined with the last part of the original word. When there are no positional parameters, "$@" and $@ expand to nothing (i.e., they are removed).

A more succinct practical+relevant example below.

$ cat a.sh
#!/bin/bash -x
find "$@" -ls
$ ./a.sh foo bar blah
+ find foo bar blah -ls
15481123719088698      4 -rw-rw-rw-   1 steve    steve           4 Jun 30 19:29 foo
17451448556173323      0 -rw-rw-rw-   1 steve    steve           0 Jun 30 19:29 bar
find: ‘blah’: No such file or directory
$
ilkkachu
  • 138,973
steve
  • 21,892