c program to implement the unix or linux command to
implement
ls -l >output.txt
Answer Posted / gunjan
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
int main(int argc, char* argv[])
{
DIR *mydir;
struct dirent *myfile;
struct stat mystat;
mydir = opendir(argv[1]);
while((myfile = readdir(mydir)) != NULL)
{
stat(myfile->d_name, &mystat);
printf("%d",mystat.st_size);
printf(" %s
", myfile->d_name);
}
closedir(mydir);
}
Is This Answer Correct ? | 3 Yes | 5 No |
Post New Answer View All Answers
What is the fork() system call?
Explain the mount system calls?
Explain the difference between command and utility in unix?
Explain the mount and unmount system calls?
Explain c program to implement the unix or linux command to implement ls -l >output.txt?
Tell me how to protect a process from others to kill?
What are the possible return values of kill() system call?
Explain the unmount system calls?
What is the difference between command and utility in unix?
Name the command which is used to execute system calls from exe?
The very first process created by the kernel in unix is?
What is the first process created by the kernel in unix?
How to protect a process from others to kill?