20250415 Flashcards
To invoke several commands on a single commandline, no matter which one fails or succeeds:
We use semicolons ;
To run a sequence of commands, but stop execution if any of them fails
Seperate them with &&
To run a sequence of commands, stopping execution as soon as one succeeds
Separate them with ||
What does pipe |
operator do?
What does the sort
command do in Linux?
It arranges lines in a file or input in order, like alphabetical or numerical order.
How do you sort lines in a file alphabetically?
Use sort filename.txt
How do you sort numbers correctly (not alphabetically)?
Use sort -n filename.txt
How do you sort in reverse order?
Use sort -r filename.txt
How do you remove duplicates while sorting?
Use sort -u filename.txt
How to tell the shell to remove the command and substitute the commands’s output?
surrund it with backticks or $(<command>)
echo this year is $(date +%Y)