ls -l: What happens behind the scenes?

A step by step explanation of what happens when you type ls -l and hit Enter in a shell


In C, a function that carries out such a task is getline();it receives &buffer (the address of the first character position where the input string will be stored), &bufsize ( is the address of the variable that holds the size of the input buffer, another pointer) and where to take the input from (in this case stdin because the standard input is read). Getline returns 1 if it finds an input and 0 if it encounters the end of the file (EOF). If there is some error in getting a record, such as a file that cannot be opened, then getline returns -1.

In C, the strtok() function is used to split a string into a series of tokens based on a particular delimiter. A token is a substring extracted from the original string. The general prototype for the strtok() function is:
char *strtok(char *str, const char *delim)
Where str is the string which is to be split and delim is the character on the basis of which the split will be done. The function performs one split and returns a pointer to the token split up. A null pointer is returned if the string cannot be split.

Then it has to be in the PATH!



Can you execute the program already!?

So… is that it?



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store