Raf
Raf

Reputation: 1757

What is $'\0' in bash?

What does this $'\0' mean in the -d option for the read command?

I understand it is being used as a delimiter for the read command, but I'm lost with the syntax used.

find path/to -type f -print0 | while read -d $'\0' file; do
        grep "Willy" "$file"
done

Upvotes: 2

Views: 137

Answers (1)

Raf
Raf

Reputation: 1757

Turns out it is a nice trick to use find and read together to search through several files.

The $'\0' is the null character, and if the find command is used with the -print0 option, its results will be separated by the null character.

It is well explained here.

Upvotes: 4

Related Questions