gow
gow copied to clipboard
gfind with xargs grep fails if found file name had spaces
In my directory suppose I have a file "Uncle Fred Flits By.txt"
Now the following command fails- gfind . -name "*By.txt" | xargs grep "Pongo"
Output is: grep: ./Uncle: No such file or directory grep: Fred: No such file or directory grep: Flits: No such file or directory grep: By.txt: No such file or directory
This is expected and you'll see the same behaviour on most *nix installations. It has to do with IFS (Internal Field Separator). You can get around this by issuing this instead:
gfind . -name "*By.txt" -print0| xargs -0 grep "Pongo"