Unix - Basic Operators

In Unix, there are several basic operators that are used to combine commands and perform various operations. Some of the most commonly used basic operators include:

 

Pipe (|): The pipe operator is used to send the output of one command as input to another command. For example, the command "ls | wc -l" will list all the files in the current directory and then count the number of lines in the output.

 

Redirection (> and >>): The redirection operators are used to redirect the output of a command to a file. The ">" operator will overwrite the file with the output, while the ">>" operator will append the output to the end of the file. For example, the command "ls > output.txt" will list all the files in the current directory and save the output to a file called "output.txt".

Input redirection (<): The input redirection operator is used to redirect input from a file to a command. For example, the command "sort < input.txt" will sort the contents of the file "input.txt".

Command substitution ($()): The command substitution operator is used to execute a command and use the output as an argument in another command. For example, the command "echo $(date)" will print the current date and time.

Background execution (&): The background execution operator is used to run a command in the background, allowing you to continue using the terminal while the command is running. For example, the command "firefox &" will open the Firefox web browser in the background.

These are just a few of the basic operators in Unix. There are many other operators and commands available, and mastering them can greatly increase your productivity and efficiency in the Unix command line.