Posts

Showing posts from January, 2019

CS8461- OPERATING SYSTEMS LABORATORY-Write C programs to simulate UNIX commands like cp, ls, grep, etc.

Write C programs to simulate UNIX commands like cp, ls, grep, etc. x Before seeing the program you have to learn about what is the meaning of the following commands. cp - copy- it is used to copying contents from one file to another file. Syntax: cp Source Destination ls -list- its used to list all file names in the directory. Syntax: ls grep- The grep filter searches a file for a particular pattern of characters, and displays all lines that contain that pattern. Syntax: grep [options] pattern [files] Options Description -c : This prints only a count of the lines that match a pattern -h : Display the matched lines, but do not display the filenames. -i : Ignores, case for matching -l : Displays list of a filenames only. -n : Display the matched lines and their line numbers. Below code is included code of  both cp & ls command. Program: #include<stdio.h> #include<stdlib.h> #include<dirent.h> #define D...