The < symbol is used for input redirection. Files, for example, can be used as input.
In this case, the file.txt is taken as input, and the cat command deletes it
src=”https://linuxhint.com/wp-content/uploads/2022/02/untitled_14.png” alt=”Untitled_14″ /> Symbol: >
This symbol, known as the file redirection operator, is typically used to redirect the contents of one command/file to another by overwriting it.
<img src="https://linuxhint.com/wp-content/uploads/2022/02/untitled.png" alt="Untitled" /
Here, the > symbol is similar to 1>. This is because 1 is a file descriptor for standard output. Note that the file descriptors are as follows:
0 — Standard input, stdin 1 — Standard output,
2 — Standard error, stderr
In the previous scenario, the forward arrow was equivalent to 1>. However, we can also type 2> to forward it to the standard error.
Here, the 2> means that the error will be dumped in file2.txt.
<img src="https://linuxhint.com/wp-content/uploads/2022/02/untitled2.png" alt="Untitled2" />
The >> symbol is used to add and not to replace! The file redirection operator replaces or overwrites everything while using the >> to append.
The latter will add the two lines to the file named file.txt. The output of the file.txt will be as follows
The hashtag is used to add one-line comments in scripts. These comments are not executed/executed.
which is a single line, multiline comments look more like this;
$# The $#
symbol is used to retrieve the length or number of arguments passed through the command line. When using the $@ symbol or just $1, $2, etc., we request command line input and store its values in a variable. The $# symbol is used to retrieve the total number of arguments passed.
The latter should remove a value of 2 because there are 3 elements (hello, world, and again).
<img src="https://linuxhint.com/wp-content/uploads/2022/02/untitled7.png" alt="Untitled7" /
This symbol redirects both standard output and standard error.
In this case, the &> symbol redirects both the standard output and the standard error to the file named file.txt. Therefore, both the output generated and the error generated are placed in the same file.
<img src=”https://linuxhint.com/wp-content/uploads/2022/02/untitled6.png” alt=”Untitled6″ /
\< and \> You must compare the length of the
string or the length of the characters; this can be done through the symbols \< and \>. These two symbols are used to compare character lengths.
In this case, the word stored in a – or cat – has a character length of
3, while the word stored in b – or lynx – has a character length of 4. Therefore, the answer should be that “a is shorter than b”.
Symbol: ^^, ^ and ,,
Some symbols work to change
the case of characters. ^^ — convert all characters to uppercase
^ — convert the first letter
,, — convert all characters to lowercase
$@ or $*
The symbol $@ is equivalent to $
which equals $1 $2 $3 $4…
In this example, $1, $2, $3, $
4, and $5 are command-line entries. Alternatively, we could have written the following
This particular symbol – $? – is used to get the output state of the previously passed command
An output status of 0 indicates that the process completed successfully
The $$ symbol stores the PID of the current shell
In my case, it printed the value 2443. This is the PID of the shell.
<img src="https://linuxhint.com/wp-content/uploads/2022/02/untitled_12.png" alt="Untitled_12" /
> Symbol: 2>&1
The symbol 2>&1 redirects both
the standard output and the standard error to the standard output.
In this case, all standard output and if any error is generated, the standard error is directed to the file named file.txt
Bash scripting is a key scripting language that can be used to automate tasks. During bash scripting, we find a lot of code, but we also find special characters or symbols that are unique to bash. Each of these symbols has a particular role in bash scripting, and they are not always obvious. In this tutorial, we review some key symbols used when writing bash scripts. Obviously, there are many symbols out there; However, some are encountered so frequently that it might be necessary to know them while relying on scripting. So go ahead, without fear of the symbol from here on out!