1

Can someone elaborate the following command how does it work?

distclean: mrproper
    @find $(srctree) $(RCS_FIND_IGNORE) \
        \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
        -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
        -o -name '.*.rej' -o -size 0 \
        -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
        -type f -print | xargs rm -f
Cœur
  • 37,241
  • 25
  • 195
  • 267
user2598064
  • 157
  • 1
  • 13

1 Answers1

1

when $make distclean is issued,

find command will search the files in $(srctree) with mentioned extensions.

@find $(srctree) $(RCS_FIND_IGNORE) \
        \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
        -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
        -o -name '.*.rej' -o -size 0 \
        -o -name '*%' -o -name '.*.cmd' -o -name 'core' \)

then absolute path of each file is taken using -print option and type of file as regular file using -type f.

-type f -print

Result of find result will be redirected to rm command to delete that file. While redirecting the find command result to rm command, you need to pass the file name one by one(This is not rm -r dirname). so xargs is used to read from stdin and build the command.

some useful links about xargs.
http://www.cyberciti.biz/faq/linux-unix-bsd-xargs-construct-argument-lists-utility/
Understanding the UNIX command xargs
http://linux.101hacks.com/linux-commands/xargs-command-examples/

some links to find command
http://www.tutorialized.com/tutorial/10-examples-of-using-find-command-in-Linux/67264
http://www.thegeekstuff.com/2009/03/15-practical-linux-find-command-examples/
http://www.thegeekstuff.com/2009/06/15-practical-unix-linux-find-command-examples-part-2/

Community
  • 1
  • 1
Jeyaram
  • 9,158
  • 7
  • 41
  • 63