简体   繁体   中英

Matlab execute UNIX command not working in newer versions

I have a script that uses this line of code:

system(['cat ' inputfile ' | tr -d ''\000'' | tr -d ''\015'' >& tempfile.txt']);

to go through a text file and delete some special characters and then put it into a temp file.

This line of code works in Matlab2012 but not in 2017 as it leads to this error:

tr: Illegal byte sequence
cat: stdout: Broken pipe

Does anyone know how to get around this issue? Thank you!

The encoded format may not be supported by tr, try changing the locale (refer to https://unix.stackexchange.com/questions/141420/tr-complains-of-illegal-byte-sequence ):

system(['cat ' inputfile  ' | LC_ALL="C" tr -d ''\000''''\015'' >& tempfile.txt']); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM