answersLogoWhite

0


Best Answer

#include

#include

#include

#include

int main(int c, char *argv[])

{

DIR *ptr;

int i=0;

struct dirent *p;

ptr = opendir(“.“);

p = readdir(ptr);

if((c!=1) && (strcmp(argv[i]), “-a” 0 )

{ //child

execlp ( “/bin/ls”, “ls”, “-l”, NULL ); //execute ls

}

else

{ //parent

wait (NULL); //wait for child

printf(“\nchild complete\n”);

exit (0);

}

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a c program that simulates ls command?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write the Linux command to display the information about LS command?

Using man ls will open the manual page for the ls command. The ls command lists the files and folders in the current directory.


Which is the keyword of shell 1.shift 2.readonly 3.unset 4.ls?

answer is ls.. ls is command outside of the unix kernel.. To identify this if you do locate <command> or which<command> you can identify the source of the program.. if you do locate<keyword> or which<keyword>.. you can't identify the source of the program... :)~ss


Is ls is external or internal command?

The 'ls' command is an external command (found in /bin)


Write command to show all files and directories?

If you want everything, start at the root directory and issue the command: ls -R


Is the ls command in Linux equivalent to ls -FC?

The 'ls' command is the same in Linux and Unix systems. System Administrators may set up an alias that has the -FC or other options but the command itself with no other parameters (ls) is just the 'ls' command.


Write a C program to implement excelp system call?

You are not able to do that, but you can write a program, that uses the system-call./* exectest.c */#include int main (void){execlp ("/bin/ls", "ls", "-ld", ".", NULL);return 0;}


Linux command to list a folders contents?

The LS command: ls folder Type man ls for more details.


Write a Linux command to print the content of a given directory to a given file?

ls /this/dir/path > dirfile


Which command illustrates how to obtain helpful documentation for the ls command?

Use either the 'man' command or the 'info' command with ls to get more information on options and output.


How do you list all of the files in the current directory in Unix?

the command is - ls there are other options and flags for the ls command which can be viewed by typing man ls if you type 'man ls' in a google search, it will show you the same manual


What does man ls abcdat command do in Linux?

The command "man ls" will tell you about the 'ls' command. The last part will be ignored because it isn't part of the manual entry for the 'ls' command.The command as you can given it is most likely because you want to know what will happen when you issue the 'ls abcdat' command in Linux. The answer is that it will list out the name (in a short form) of the file or directory abcdat if it exists in your current working directory.


What is the Linux command used to list the contents of a directory?

ls will list the contents of a directory.