Skip to content

This is a custom Unix shell with three commands: word (word count), dir (directory manipulation), and date (file timestamp retrieval)

Notifications You must be signed in to change notification settings

YashovardhanSinghal/Linux-CShell

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linux-CShell

Custom Unix System Shell

This project implements a custom Unix system shell with three specific commands: word, dir, and date. The shell is designed to be used in a C Shell environment and provides functionality as specified by the project guidelines.

Commands

1. word

Syntax

word [-n | -d] [file_name]
  • word: Built-in command to count words in a text file.
  • Options:
    • -n: Ignores new line characters.
    • -d: Displays the difference between word sizes of two text files.
  • file_name: The name of the text file.

Examples

# Count words in a file
word myfile.txt

# Count words excluding new line characters
word -n myfile.txt

# Display the difference between word sizes of two files
word -d file1.txt file2.txt

2. dir

Syntax

dir [-r | -v] [dir_name]
  • dir: External command to create and change the path to a directory.
  • Options:
    • -r: Removes the directory if it already exists and creates a new one.
    • -v: Prints a message for each step in the command execution.
  • dir_name: The name of the directory.

Examples

# Create and change path to a directory
dir mydirectory

# Remove and recreate directory if it already exists
dir -r existing_directory

# Print messages for each step
dir -v another_directory

3. date

Syntax

date [-d | -R] [file_name]
  • date: External command to return the last modified date and time of a file.
  • Options:
    • -d: Displays time described by STRING.
    • -R: Outputs date and time in RFC 5322 format.
  • file_name: The name of the file.

Examples

# Get last modified date and time of a file
date myfile.txt

# Display time described by a specific string
date -d "2023-01-01 12:00:00" myfile.txt

# Output date and time in RFC 5322 format
date -R another_file.txt

Implementation Details

The project consists of three separate C programs: main.c, dir.c, and date.c. The main.c file is the core of the custom shell, while dir.c and date.c contain the implementations for the dir and date commands, respectively.

Compilation

To compile the project, use the following commands:

gcc -o custom_shell main.c
gcc -o dir_command dir.c
gcc -o date_command date.c

Running the Shell

./custom_shell

Enter commands as described in the syntax examples above.

Note: Ensure that the dir_command and date_command executables are in the same directory as the custom_shell executable.

Contributors

Palak Bhardwaj Yashovardhan Singhal

License

This project is licensed under the MIT License.

About

This is a custom Unix shell with three commands: word (word count), dir (directory manipulation), and date (file timestamp retrieval)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 100.0%