Lesson 3 Flashcards

(43 cards)

1
Q

How does compression work?

A

By replacing repetitive patterns in data. For example finding a common word and replacing it with something else then creating a map to that replacement (obv more complex)

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

What are the two types of compression?

A

Lossless and Lossy

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

When is lossy compression often used?

A

For images, video or audio where loss in the original data has a marginal effect

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

Name some common lossless compression tools

A

bzip2, gzip, xz

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

What is the most common archiving tool?

A

tar

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

how do you uncompress? name the common commands

A

bunzip2, gunzip, unxz

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

How can you increase or decrease the level of compression?

A

By using -1 through -9…common among all compression tools

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

what is the syntax for a tar command to compress?

A

tar -cf newfile pathtoarchive

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

what is the syntax to untar?

A

tar -xf <file/path>

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

When using tar with gzip, bgzip2 and xz what are the commands?

A

gzip = tar -xzf
bzip2 = tar -xjf
xz = tar -xJf

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

syntax to zip recursively

A

zip -r filename filepath

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

syntax to unzip

A

unzip filename

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

how to output the contents of a compressed file?

A

zcat gzip, bzcat for bzip2

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

how do add a file to a compressed tar?

A

First you need to uncompress it so gunzip or bunzip2 or unxz…then use tar uf to add a new file

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

how to view contents of a tar without extracting it?

A

tar -tf filename

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

Which tar option instructs tar to include the leading “/” in the absolute paths?

A

-P

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

Does zip support multiple compression levels?

A

Yes same as the other compression tools

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

When extracting and archive, does tar support wildcards?

A

Yes with the –wildcards option

19
Q

How can you ensure decompressed files are lossless?

A

bzip2, gzip, and xz all have checksums built in to ensure this

20
Q

What is I/O redirection?

A

Enabled you to redirect information from or to a command by using a text file

21
Q

Which character to redirect std out to a file?

A

> for example echo "hello world" > text

22
Q

Which characters to redirect std out but add to a file?

23
Q

Which characters to redirect errors to a file?

24
Q

How to redirect standard input to a command?

A

< example:
cat < text

25
what does &> and &>> do?
They redirect BOTH std out and errors to the file, &>> just appends to it
26
explain how the cut command works
First you give it the column with -f and then a delimiter to make columns on with -d
27
what does -f do with the tail command?
Lives updates the file as you have it open so you can follow logs, etc
28
with tail and head how can you specify the number of lines to show?
`-n `
29
with sort command how can you reverse the sort?
-r command
30
Using grep, how can you search a file for certain string?
grep word filename
31
name some common grep options
-i = case insensitive -r = recursive -c = includes count of matches -v = invert the match -E = used for regex (needed for *, +, ?)
32
Using regex with grep, what are the starting and end marking characters?
start = ^ end = $
33
Grep syntax for "OR"
`grep -E "foo|bar" filename`
34
what does the question mark operator do?
it makes the preceding pattern optional (zero or one)
35
What does it mean to define the interpreter?
use `which bash` to determine the type of interpreter you want to use as the shebang
36
in bash, how can I assign a variable to an input from the command line?
foo=$1 applies from 1-9
37
How to get the number of arguments passed into a bash script?
$#
38
what does bash if then syntax look like?
```base if [ condition ] then ... else ... fi ```
39
List common bash comparison operators
```bash -eq -ne -gt -ge -lt -le ```
40
how to get the exit code of the previously run command?
echo $?
41
What does the wildcard character $@ or $*
Contains all arguments passed to the script in an array
42
with echo how can you suppress new lines?
-n
43
what does "shift" do in bash?
Removes the first element of an array