Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's meaning of -print0 in following command

Tags:

linux

shell

I am using following command in Mac to replace string. Here I have a question about -print0. What's usage of it?

find skeleton/src/IO.Swagger/Controllers -name '*.cs'  -print0| xargs -0 sed -i "" "s/namespace IO.Swagger.Controllers/namespace Abc.GroupA.TableLocalService.Controllers/g"
like image 651
richard Avatar asked Dec 12 '25 11:12

richard


1 Answers

With -print0, find will separate the filenames with a null character (a zero byte). xargs must then be called with -0 (or --null, I recommend using long options in scripts, which increase readability, and reserve shortenings for disposable commands in an interactive console).

This way, you can use spaces or whatever characters, including new-lines, in the filenames.

like image 183
Raúl Salinas-Monteagudo Avatar answered Dec 15 '25 04:12

Raúl Salinas-Monteagudo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!