Multi-line string with extra space (preserved indentation)

Heredoc sounds more convenient for this purpose. It is used to send multiple commands to a command interpreter program like ex or cat The string after << indicates where to stop. To send these lines to a file, use: You could also store these lines to a variable: This stores the lines to the variable named VAR. When printing, remember the … Read more

-bash: syntax error near unexpected token `)’

It is not possible to escape single quote in single quotes. Use ” ” instead Also, there are other ways to deal with this problem: All these should print quote’test as a single parameter. Which means that another great solution for your problem is: I have only placed a dollar sign $ right before the … Read more

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