xargs:tldr:67693
This command is used to find and delete files matching a certain pattern or name.
Here's a breakdown of each part of the command:
-
find . -name ${'*-backup'}
: This part starts thefind
command. The period (.
) represents the current directory, and-name
is used to specify the name pattern to search for.${'*-backup'}
is a shell variable that is expanded to*-backup
, indicating that we're searching for files ending with "-backup" in their name. -
-print0
: This option is used to print the found filenames, separated by null characters. It's useful when dealing with filenames containing spaces or special characters. -
|
: This is a pipe symbol, which redirects the output of the previous command (find
) to the input of the next command (xargs
). -
xargs -0 rm -v
:xargs
is a command that reads items from standard input (in this case, the filenames fromfind
) and executes another command (rm
) with those items as arguments.-0
tellsxargs
to expect null-delimited input.rm
is the command used to remove files, and-v
is an option to make it verbose, which means it will display the names of the files being deleted.
So, overall, this command finds all files in the current directory and its subdirectories that match the pattern *-backup
in their name, prints their names (using null characters as separators), and then uses xargs
to delete the found files with rm
while also displaying their names.