Hi,
Just found out about preprocessor macros, and was trying to create a popen command that would include a changing directory.
I tried the following:
Code:
#define COMMAND(dir) "find " #dir " -type f -printf '%T@ %t %p\\n' | sort -k 1 -nr | rev | cut -d' ' -f1 | rev"
And it does what I need with the following:
Code:
printf("%s\n", COMMAND("/home/user/directory"));
But I'm now trying to use a '#define' as the argument for the macro, but it just uses the NAME rather than the value:
Code:
printf("%s\n", COMMAND(DIRECTORY));
Prints:
Code:
find DIRECTORY -type f -printf '%T@ %t %p\n' | sort -k 1 -nr | rev | cut -d' ' -f1 | rev
Instead of:
Code:
find "/home/user/directory" -type f -printf '%T@ %t %p\n' | sort -k 1 -nr | rev | cut -d' ' -f1 | rev
What am I doing wrong? Is this even possible?