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,732
  • 7
  • 32
  • 48
A.K
  • 55
  • 4
  • 2
    Possible duplicate of [What is the difference between $\* and $@?](https://unix.stackexchange.com/questions/41571/what-is-the-difference-between-and) (going by [what does $* mean in shell](https://unix.stackexchange.com/questions/141287/what-does-mean-in-shell)) – muru Jul 01 '19 at 06:33

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
  • 133,243
  • 15
  • 236
  • 397
steve
  • 21,582
  • 5
  • 48
  • 75