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)
- Tips How To Recover Deleted Files on Windows PC Free and Easily - October 8, 2018
- iKeyMonitor Android Tracking App Review - September 4, 2018
- “Open Sesame” Vulnerability That Let Users Hack Windows 10 Was Demonstrated at Black Hat Conference - August 12, 2018