I am developing a C terminal application that verifies if a file extension matches the file real type (ex: file with txt extension but contains PNG image). My question is: how do I use pipes in the command written in the exec function?
The following code line represents what I am trying to do: args.file_arg[i] is the filename (there will be multiple files being verified).
execlp("file", "file", (char *)args.file_arg[i], NULL)
The output returns:
EI_PA.1S2021-22.proj_checkFile---v2.pdf: PDF document, version 1.7
and I want to substitute spaces to hashtags, to then cut the desired column and show only the file "real" extension.
Can I do that without using the pipe function in C?