forked from Az0x7/h4cker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f423031
commit c85817a
Showing
1 changed file
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# Linux metacharacters | ||
|
||
1. `;` : Separates commands. | ||
``` | ||
command1 ; command2 # Run command1, then run command2 regardless of whether command1 succeeded. | ||
``` | ||
2. `&` : Background execution. | ||
``` | ||
command & # Runs "command" in the background. | ||
``` | ||
3. `&&` : AND operator. | ||
``` | ||
command1 && command2 # Run command1, then run command2 only if command1 succeeded. | ||
``` | ||
4. `||` : OR operator. | ||
``` | ||
command1 || command2 # Run command1, then run command2 only if command1 failed. | ||
``` | ||
5. `|` : Pipe operator. | ||
``` | ||
command1 | command2 # Output of command1 is passed as input to command2. | ||
``` | ||
6. `()` : Command group. | ||
``` | ||
(command1; command2) # Group commands into a subshell. | ||
``` | ||
7. `{}` : Command block. | ||
``` | ||
{ command1; command2; } # Group commands in the current shell. | ||
``` | ||
8. `$()` : Command substitution. | ||
``` | ||
echo $(command) # Runs "command" and substitutes its output in place. | ||
``` | ||
9. ` `` ` (Backticks): Another way of command substitution. | ||
``` | ||
echo `command` # Same as above, but this syntax can be harder to spot. | ||
``` | ||
10. `>` : Output redirection. | ||
``` | ||
command > file # Redirect the output of command to a file, overwriting the file. | ||
``` | ||
11. `>>` : Append output. | ||
``` | ||
command >> file # Append the output of command to a file. | ||
``` | ||
12. `<` : Input redirection. | ||
``` | ||
command < file # Use "file" as input for command. | ||
``` | ||
13. `2>` : Error redirection. | ||
``` | ||
command 2> file # Redirect the error output of command to a file, overwriting the file. | ||
``` | ||
14. `2>>` : Append error output. | ||
``` | ||
command 2>> file # Append the error output of command to a file. | ||
``` | ||
15. `&>` : Redirect all output (stdout and stderr). | ||
``` | ||
command &> file # Redirect all output of command to a file, overwriting the file. | ||
``` | ||
16. `*` : Wildcard. | ||
``` | ||
ls *.txt # List all .txt files. | ||
``` | ||
17. `?` : Single character wildcard. | ||
``` | ||
ls ?.txt # List all .txt files with a single character name. | ||
``` | ||
18. `[]` : Character class. | ||
``` | ||
ls [ab]*.txt # List all .txt files starting with 'a' or 'b'. | ||
``` | ||
19. `!` : Negation. | ||
``` | ||
command1; ! command1 # Execute command1, then execute command1 again only if the first execution failed. | ||
``` | ||
20. `#` : Comment. | ||
``` | ||
# This is a comment in Bash. | ||
``` | ||
21. `\$` : Escape character. | ||
``` | ||
echo \$HOME # prints $HOME, not the value of the variable. | ||
``` | ||
22. `\"` : Escape character for quotes. | ||
``` | ||
echo "This is a \"quote\"" # prints This is a "quote". | ||
``` | ||
Be careful, especially when using redirections, as they can overwrite your files without warning if you're not careful. |