This program is designed to imitate the implementation of the cat
command using various system calls like open()
, close()
, read()
, write()
.
The program is completely written in C
, and uses the default compiler for FreeBSD
which uses the command cc
to get compile.
- Clone or download this repository
- Navigate to the directory and open it on terminal
- Compile the source code using
cc mycat.c
- Change the name of the executable to mycat using the command
mv a.out mycat
- Run the command
./mycat file1.txt file 2.txt file3.txt
- you can replace files with whatever files you would like
open()
: The open() system call opens the file specified by file name. and takes a second argument of flags.close()
: The close() system call closes the file after finishing I/O operationread()
: read() reads up to an x number of bytes from a certain file into the buffer. A buffer has to be created first.write()
: write() writes up to an x number bytes from the buffer starting at a certain point to the file referred to in the function declaration.perror()
: perror() prints a system error message.
O_RDONLY
: short for Read Only
./mycat file1.txt file2.txt file3.txt
: output from each file will be printed to standard output../mycat file100.txt
: an error will be printed to standard output../mycat
: no output will be printed../mycat file1 | grep string1
: A line containing "string1" will be printed.
Assignment By: Ahmed SalahEldin Farouk Elkashef - 1410216