20250415 Flashcards

1
Q

To invoke several commands on a single commandline, no matter which one fails or succeeds:

A

We use semicolons ;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

To run a sequence of commands, but stop execution if any of them fails

A

Seperate them with &&

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

To run a sequence of commands, stopping execution as soon as one succeeds

A

Separate them with ||

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does pipe | operator do?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the sort command do in Linux?

A

It arranges lines in a file or input in order, like alphabetical or numerical order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you sort lines in a file alphabetically?

A

Use sort filename.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you sort numbers correctly (not alphabetically)?

A

Use sort -n filename.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you sort in reverse order?

A

Use sort -r filename.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you remove duplicates while sorting?

A

Use sort -u filename.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to tell the shell to remove the command and substitute the commands’s output?

A

surrund it with backticks or $(<command>)

echo this year is $(date +%Y)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly