Files Flashcards

1
Q

Wildcards

A
A character or string used for pattern
matching.
Wildcards can be used with most commands.
○ ls
○ rm
○ cp
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
● * - matches zero or more characters.
○ *.txt
○ a*
○ a*.txt
● ? - matches exactly one character.
○ ?.txt
○ a?
○ a?.txt
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Input / Output Types

A

I/O Name I/O File Descriptor

Stand. Inp. stdin 0
Stand. Outp. stdout 1
Stand. Err. stderr 2

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

Redirection Symbols
>
»
<

&

A

>

 Redirects standard output to a file.
     Overwrites (truncating) existing contents.

> >

Redirects standard output to a file.
    Appends to any existing contents.

< Redirects input from a file to a command

& Used with redirection to signal that a
file descriptor is being used.

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

Redirection Example

A

2>&1 Combine stderr and standard output.

2>file Redirect standard error to a file.

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

Searching Files Syntax

and Options

A

Display lines matching a pattern.

grep [pattern] [file]
_______________________
-i Perform a search, ignoring case.
-c Count the number of occurrences in a file.
-n Precede output with line numbers.
-v Invert Match. Print lines that don’t match.

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

Searching for Text in Binary Files

A

Display printable strings.

> strings

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

Pipes Syntax

A

command-output | command-input

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

Viewing Files with Nano Editor

A

Open file
>nano [file directory]

Help/ man pages: Ctrl+G
Exit man pages: Ctrl+X

Quit Nano: Ctrl+X > It will ask you if you want to save

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

Viewing Files in Real Time - e.g for Logs

A

tail -f [file]

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

Viewing / Editing files with VI Editor

A

dd

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

Viewing / Editing files with VI Editor

A
vi [file]      Edit file.
vim [file]    Same as vi, but more features.
view [file]   Starts vim in read-only mode.
\_\_\_\_\_
i Insert at the cursor position.
I Insert at the beginning of the line.
a Append after the cursor position.
A Append at the end of the line.
\_\_\_\_\_\_\_\_\_\_\_
\:w Writes (saves) the file.
\:w! Forces the file to be saved.
\:q Quit.
\:q! Quit without saving changes.
\:wq! Write and quit.
\:x Same as :wq.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

vi Editor switches for navigation

A
k   Up one line.
j   Down one line.
h   Left one character.  
l  Right one character.
w  Right one word.
b  Left one word.
^  Go to the beginning of the line.
$ Go to the end of the line.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly