Write a C program to list for every file in a directory, its inode number and file name.
AIM:
14.Write a C program to list for every file in a directory,its inode number and file name.
Program:
#include<stdlib.h> #include<stdio.h> #include<string.h> main(int argc, char *argv[]) { char d[50]; if(argc==2) { bzero(d,sizeof(d)); strcat(d,"ls "); strcat(d,"-i "); strcat(d,argv[1]); system(d); } else printf("\nInvalid No. of inputs"); }
output:
student@ubuntu:~$ mkdir dd student@ubuntu:~$ cd dd student@ubuntu:~/dd$ cat >f1 hello ^z student@ubuntu:~/dd$ cd student@ubuntu:~$gcc –o flist.out flist.c student@ubuntu:~$./flist.out dd hello 46490 f1
-
UpdatedOct 23, 2014
-
Views24,262
You May Like
Write a Shell script to find factorial of a given integer.
Write in C the following Unix commands using system calls A). cat B). ls C). mv
Write a Shell script that displays list of all the files in the current directory to which the user has read, Write and execute permissions.
Write a Shell script that accepts a filename, starting and ending line numbers as arguments and displays all the lines between the given line numbers.
Write a C program to emulate the Unix ls-l command.
Write a Shell script to list all of the directory files in a directory.