Linked Questions

0
votes
3answers
63 views

I have if else question but I am not sure the answer is true? [duplicate]

I am running this on Linux: $ number=4 $ test $number -eq 4 $ echo $? 0 $ test $number -lt 2 $ echo $? 1 Are the results (0 and 1) true ?
2
votes
1answer
71 views

Why “ >/dev/console” for remote beep (echo-command)

I've learned that this command: echo -e "\a" triggers a beep on the local system, whereas this command: echo -e "\a" >/dev/console triggers a beep on a remote system. Why is this? What is the &...
6
votes
2answers
94 views

ed command: Delete from line 1 until the first blank line

I came across this code from a textbook; the book only says that 1,/^[ ]*$/d means “Delete from line 1 until the first blank line.” What does each character specifically mean? ed $1 << EOF ...
0
votes
1answer
18 views

multiple yum repos with name=packages-microsoft-com-prod

A group of Amazon Linux 2 instances have duplicate instances of name=packages-microsoft-com-prod in redundant yum repositories with different names. What is a safe way to remove the duplicate ...
0
votes
0answers
14 views

something wrong when overwriting file [duplicate]

I was trying to delete the last line and overwrite the file. But I failed for some reason. I could write the modified text to another file though. $cat > file.txt a b c $set "$d" file.txt > ...
0
votes
0answers
22 views

Explain this forking syntax [duplicate]

This is excerpted from ~/.bashrc on a RasPi. if [ -z "${SSH_TTY}" ]; then startx > /dev/null 2>&1 fi I'm fairly sure the if statement means not for ssh tty sessions ie when ...
-2
votes
1answer
68 views

What is the meaning of “<-” operator in bash? [closed]

In the installation instructions for KnockPY it says: nano knockpy/config.json <- set your virustotal API_KEY I need to understand what exact is '<-' doing in this command.
18
votes
2answers
12k views

What does the < (left chevron / triangle bracket) do? [duplicate]

I understand that the > (right chevron) is for redirecting the STDOUT of a program to a file, as in echo 'polo' > marco.txt will create a text file called marco.txt with polo as the contents ...
0
votes
3answers
227 views

Purpose of '&& bash' in a command (not the '&&' part, the 'bash' part)

I just saw the list of commands below on a web page - they install a static version of ffmpeg in the user's ~/bin directory. The commands are not part of a script, the user is supposed to copy and ...
0
votes
1answer
92 views

Writing file to specific USB device

I am looking to write the output of cat /var/log/dpkg.log to a file rather than viewing on the screen. I have tried cat /var/log/dpkg.log | file.txt without any success. Ultimately I want ...
119
votes
4answers
72k views

Precedence of the shell logical operators &&, ||

I am trying to understand how the logical operator precedence works in bash. For example, I would have expected, that the following command does not echo anything. true || echo aaa && echo ...
2
votes
2answers
77 views

How do I replace words with increasing numbers?

For example, the only thing in file.txt looks like this: xxxxxxxxxHAHAxxxxxxHOHOxxxxxxx I hope to replace HAHA with seq 1 3 and replace HOHO with seq 5 7, so the output should be: ...
6
votes
6answers
652 views

Checking for the existence of multiple directories

I want to check for the existence of multiple directories, say, dir1, dir2 and dir3, in the working directory. I have the following if [ -d "$PWD/dir1" ] && [ -d "$PWD/dir2" ] && [ -...
15
votes
4answers
1k views

Precedence of Pipe (|) and logical and (&&) in bash

The classic scenario with Operator Precedence, you have a line like : (cd ~/screenshots/ && ls screenshot* | head -n 5) And you don't know if it's parsed ((A && B) | C) or (A &&...
1
vote
1answer
7k views

What is the different between ls > list and ls >> list? [duplicate]

I was wondering what the difference is between ls > list and ls >> list is and what the purpose of these commands is?

15 30 50 per page