Bash has a way to specify strings with escaped characters like so: $'\r\n' which gives a string containing carriage return and newline characters.

The `read` built-in can take a delimiter with the -d flag. Combining these lets you use a null character: read -d $'\0'

Useful in some of the same places you might use xargs(1).

find . -name ... -print0 | while read -d $'\0'; do ./foo "$REPLY"; done

#bashTricks #xargs #bash #shellTricks

@egypt i wish bash had a good equivalent for perls chomp();

@Viss you can kinda do it with string substitution. This will remove a single trailing newline: ${foo%[$'\n']}

Or a trailing space: ${foo%[[:space:]]}

The replacement in a % or %% substitution is like a file glob, not a regexp, so you can't say one-or-more.

@egypt or just do xargs -0 ?

@snowchyld because I don't know how to do this with xargs

| while read -d $'\0'; do
./foo "${REPLY%.app}" |& grep -q thing && echo $REPLY; done