To understand xargs better

前端 未结 3 1491
一个人的身影
一个人的身影 2021-01-20 14:14

I want to understand the use of xargs man in Rampion\'s code:

screen -t man /bin/sh -c \'xargs man || read\'

Thanks to Ram

3条回答
  •  误落风尘
    2021-01-20 14:54

    xargs gathers arguments from stdin and executes the command given with those arguments.

    so cat is waiting for something to be typed, and then xargs is running man with that input.

    xargs is useful if you have a lot of files to process, I often use it with output from find. xargs will stuff as many arguments as it can onto the command line.
    It's great for doing something like

    find . -name '*.o' -print | xargs rm
    

提交回复
热议问题