In the shell, what does ” 2>&1 ” mean?

File descriptor 1 is the standard output (stdout).File descriptor 2 is the standard error (stderr). Here is one way to remember this construct (although it is not entirely accurate): at first, 2>1 may look like a good way to redirect stderr to stdout. However, it will actually be interpreted as “redirect stderr to a file named 1“. & indicates that what follows and precedes is … Read more

What does export PS1=”\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ ” mean in MacOS’ bash Terminal?

export is used to set environment variable in operating system. This variable will be available to all child processes created by current Bash process ever after. PS1 is the primary prompt which is displayed before each command, thus it is the one most people customize. read more: https://wiki.archlinux.org/index.php/Bash/Prompt_customization#Prompts And the statement: \[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$dictates how the prompt is going to look … Read more

How to compare strings in Bash

Using variables in if statements If you want to do something when they don’t match, replace = with !=. You can read more about string operations and arithmetic operations in their respective documentation. Why do we use quotes around $x? You want the quotes around $x, because if it is empty, your Bash script encounters … Read more

How to create a file in Linux from terminal window? [closed]

Depending on what you want the file to contain: touch /path/to/file for an empty file somecommand > /path/to/file for a file containing the output of some command. eg: grep –help > randomtext.txt echo “This is some text” > randomtext.txt nano /path/to/file or vi /path/to/file (or any other editor emacs,gedit etc)It either opens the existing one for editing or creates & opens … Read more