Skip to content

Short programs to deal with files (Head /Tail /Longlines /cd /diff /seq )

Notifications You must be signed in to change notification settings

IvanPerez9/OS-Commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OS-Commands

Bash Shell Twitter Follow

This repository is a small collection of several Operating System commands, some of them already implemented in the UNIX systems, but others expand the OS ones to provide better functionality. Operating systems project 1.

How to compile this proyect:

We use Wall and Wextra as options to request or suppress warnings

Wall: This enables all the warnings about constructions that some users consider questionable, and that are easy to avoid (or modify to prevent the warning), even in conjunction with macros.

Wextra: This enables some extra warning flags that are not enabled by -Wall. (This option used to be called -W. The older name is still supported, but the newer name is more descriptive.)

$ make
gcc -Wall -Wextra libreria.c test.c -o test

There are other commands that are not in test.c file and they are not for the university project

$ make
gcc -Wall -Wextra myDiff.c -o myDiff

You can change "myDiff" for other command name

What is in the repository?

1.Inside Test.c ( University Project )

1.1 Tail:

File that implements a function which prints the last n lines of its input. By default, n is 10. The tail command copies the named file to the standard output beginning at a designated place. If no file is named, the standard input is used.

How does it work?
$ ./test tail <N> <file> 

1.2 Head:

File that implements a function which copy the first "n" bytes of a file into a new one. The number of bytes can be specified. The first specified file is the source and the second one is the destination one. In case that the second file does not exist, it will be created.

How does it work?
$ ./test head <N> <file> 

1.3 Longlines:

File that implements a function which prints the longest lines of its input. By default, n is 10.

How does it work?
$ ./test longlines <N> <file> 

2.myCd

Command to change the directory/folder of the terminal's shell. You can press the tab button in order to auto complete the directory name

How does it work?
$ ./myCd [directory]

3.myDiff

File that implements a function which compares 2 existing files and determine if they are equal or not.

How does it work?

$ ./myDiff <file1> <file2>

4.mySeq

Print a sequence of numbers.

mySeq [OPTION]... LAST

mySeq [OPTION]... FIRST LAST

mySeq [OPTION]... FIRST INCREMENT LAST

How does it work?

$ ./mySeq [First] [Increment] [Last]

Requirements:

These commands are designed to work in a UNIX (GCC Compiler needed). Max OSX or Any Linux distribution