-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathls.c
More file actions
35 lines (30 loc) · 624 Bytes
/
ls.c
File metadata and controls
35 lines (30 loc) · 624 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//Program implementing Ls Command of Unix To Display The Contents Of The HardDisk
#include<stdio.h>
#include<stdlib.h>
#include<dirent.h>
void main(int argc, char *argv[])
{
DIR *lan;
struct dirent *wan;
if(argc<2)
{ lan=opendir(".");
}
else
{ lan=opendir(argv[1]);
}
while(wan=readdir(lan))
{ if(wan->d_name[0]!='.')
{ printf("%s \t", wan->d_name);
}
}
closedir(lan);
printf("\n");
}
/*
OUTPUT
===============
./a.out /
tmp initrd.img lost+found vmlinuz var cdrom boot selinux
srv vmlinuz.old run media mnt opt initrd.img.old bin
proc dev root home sbin etc sys usr lib
*/