[0-9]
means any character from 0
through 9
. $
means the end of a line. So your grep
will find any line (i.e., filename) that ends with a digit, and xargs
will copy them each to /tftpboot
.
Of course, you'll have some surprises if any of those filenames contain spaces. You can do this entirely within the shell in zsh (and I think in recent versions of bash):
cp /localdir/**/*[0-9] /tftpboot
addendum: If you're asking about the funny quoting, that will work, though it's not very human-friendly.
The key is that you can have quoted strings and non-quoted strings right next to each other in shell, and they'll become a single string; echo "fo"ob'ar'
will produce foobar
.
The first part is quoted because [
is special to bash. ]
is also special, but since bash never saw a special (unquoted) [
, it leaves the ]
alone. $
would normally substitute a variable, but nothing comes after it, so bash leaves that alone too.
The string that actually gets passed to grep is still [0-9]$
.