Linked Questions

0
votes
3answers
64 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.
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
659 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 &&...
0
votes
2answers
67 views

Command working in interactive shell, but not inside script

I have a text file named crn.txt containing text below: 9 1 * * 3,6 /opt/testtingtools/kos/bin/cos.sh 55 23 * * * /opt/testtingtools/tqdaily.sh 2>>/opt/toolcheck/extract.err 50 11 * * 6 /opt/...
6
votes
3answers
814 views

How can I output a command to a file, without getting a blank file on error?

I'm trying to run a command, write that to a file, and then I'm using that file for something else. The gist of what I need is: myAPICommand.exe parameters > myFile.txt The problem is that ...
9
votes
1answer
598 views

Redirecting stdout from two programs

I'm running a memory check tool (prog1) on a C++ code (prog2), both of which give me a huge and detailed output. In order to chase down some bugs I need to save this output to a file. I tried ...
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 ...
1
vote
3answers
54 views

How to add a path before the first character of each line in a file.txt and save the same file with those edits? [duplicate]

I have a file that has some lines like: account_1 account_2 account_3 I have to add a path like /home/info/ before each line and save the same file with those updates like this: /home/info/...

15 30 50 per page