I am trying to clean some embedded null characters is a csv file using this command below
tr -cd '\11\12\15\40-\176' datafile.csv
This command works fine when i run this directly on a linux terminal. However when I try to execute this via R using system command like this below
system(" 'tr -cd '\11\12\15\40-\176' datafile.csv' ")
i get an error,
sh: tr -cd : command not found
: command not found
I suspect this is something related to escaping some stings, need help resolving this error.
I believe it is the extra pair of single quotes that messes things up. This worked on my end, see if you can make it work.
system("printf '\11 eleven \12 \13 fifty-eight \15 \
55 \40 \150 \176 \n one, two three\n' > so-test.txt")
system("cat so-test.txt")
system("tr -cd '\11\12\15\40-\176' < so-test.txt > so-test2.txt")
system("diff test.txt test2.txt")
PS: always include a reproducible example when asking questions like this. I don't know if my example makes sense, I think your method of removing null characters looks a little strange.