Even though the GUI in the Linux has come a long way over the past few years, the terminal always beats the GUI in terms of its raw power and usability. One of the most commonly used Linux commands is the ls command. The “ls” is a Linus shell command is which is used to print all the files and directories in the present directory in the form of a list.
0001.pcap Desktop Downloads index.html install.log.syslog Pictures Templates anaconda-ks.cfg Documents fbcmd_update.php install.log Music Public Videos
This command can also be used in many ways by just tweaking the letters and symbols with it. Some examples are:
-> ls -l (-l is a character, not one) shows file or directory, modified date and time, size, file or folder name and also owner of file and it’s permission.
-> To see the list including hidden files, use ls -a.
-> Use -lh option to see sizes in human readable format.
Now that we know the usefulness of this command, its time for us to know what we came here for:
C program to implement the LS command
- int main(int argc,char **argv)
- struct dirent **namelist;
- int n;
- if(argc < 1)
- else if (argc == 1)
- n = scandir(argv, &namelist, NULL, alphasort);
- if(n < 0)
- while (n–)
We hope you learnt something new today.
I do not claim the ownership of this code, as it was sourced form here.
Latest posts by Unallocated Author (see all)
- How To Ensure Spam Protection And Secure Your Website - January 8, 2019
- Watch Netflix Content From Wherever - December 10, 2018
- Sheger Payment Gateway Hacked By Shad0wSec - November 19, 2018