I'm developing a Cocoa app that has to execute some terminal commands. One of these looks like:
printf "\xc5\x20\x00\x00" >> aFile.txt
I tried with NSTask (but I'm not sure how to split the arguments):
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/bin/printf"];
[task setArguments:[NSArray arrayWithObjects:@"\"\\xc5\\x20\\x00\\x00\"",
@">>",
@"aFile.txt", nil]];
[task launch];
All I get is:
printf: missing format character
So I think that ">>" is not a printf argument but an internal terminal command.
How can I simulate that command in Objective C?