This project is a basic Command Line Interpreter (CLI) inspired by Unix/Linux shells. The CLI allows users to execute common system commands and includes internal commands for additional functionality.
The CLI supports executing standard system commands, enabling users to interact with the file system and manage files. Supported commands include:
pwd: Prints the current working directory.cd <directory>: Changes the current directory to the specified path.ls: Lists files in the current directory.ls -a: Lists all files, including hidden files.ls -r: Lists files in reverse order.
mkdir <directory>: Creates a new directory.rmdir <directory>: Removes an empty directory.touch <file>: Creates a new file or updates the timestamp of an existing file.mv <source> <destination>: Moves or renames files and directories.rm <file>: Removes a specified file.cat <file>: Displays the content of a specified file.- Redirection and Pipes:
>: Redirects output to a file, creating it if it doesn't exist.>>: Appends output to an existing file.|: Pipes output from one command to another (if applicable).
The CLI also includes internal commands:
exit: Terminates the CLI session.help: Displays a list of available commands and usage instructions.
- Java Development Kit (JDK) version 8 or higher.
- Clone the repository:
git clone https://github.com/your-username/cli-project.git
- Navigate to the project directory:
cd cli-project - Compile the Java files:
javac *.java - Run the program:
java CLI
- After running
CLI, you’ll be presented with a command prompt. - Enter any of the supported commands listed above to interact with the CLI.
- Use
helpfor a list of available commands. - Use
exitto close the CLI session.
- To print the current directory:
pwd - To create a new directory named
test:mkdir test - To display contents of a file named
example.txt:cat example.txt
- To redirect the output of
lsto a file:ls > output.txt