Week 1 - File and Text Manipulation Flashcards

1
Q

What command do you use to view files?

A

cat

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

What is cat short for?

A

concatenate

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

How do you limit viewing large file output to 1 page at a time? What command? Can also be used to view a file
windows

A

more

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

What commands can you use to navigate ‘more’? W

A

Enter advance one line
Space advance one page
Q to exit
arrows

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

Using cat, how do you only see only the beginning or ending lines?

A

You use the parameters:
-Head #of lines
-Tail #of lines

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

In Linux, what command to view file contents?

A

cat

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

In Linux, how do you customize the output size of the view file contents command? Can also be used to view a file

A

less

LESS IS MORE LOL

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

In the less program in Bash, what are the different commands you use to navigate around the text?

A

q to exit
g to go to the beginning
G to go to the end
/word_search

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

How do you open a Notepad++ and create a file on the same command line? w

A

start Notepad++ filename.txt

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

What’s the command to open a program? w

A

start

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

What’s the command in Linux to create a file using a Linux popular text editor? This also allows you to create/modify a text file in the Shell

A

nano filename

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

What does the ^K mean? (the carrot)

A

to use Control + K

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

With what command do you see the actual command that gets executed in Powershell?

A

Get-Alias (command)

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

What are 2 ways to execute commands in PowerShell?

A
  1. use cmd.exe and \? for the equivalent of Get-Help for cmd.exe commands
  2. use the real PowerShell commands (relatable aliases) and Get-Help for more information
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you configure the service to index file contents? Windows. 5 steps

A
  1. indexing options (search bar)
  2. Users
  3. Advanced
  4. File Types
  5. Select ‘Index Properties and File Types’
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What’s the shortcut to “Find in Files” in Notepad++? (searches specific sectors depending on settings)

A

CTRL + Shift + F

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

What are 2 ways to search within files on Windows? What should be done first?

A

First: enable indexing options

  1. use Notepad++
  2. use PS command sls
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What does sls stand for? w

A

select desk string

finds strings of characters or words

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

What’s a regular expression? w

A

a pattern-matching language used by sls to find text that matches

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

What is a “string”?

A

A way for the computer to represent text

strings of characters, words, etc

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

What powershell command lets you search for a word in a file?

A

sls
or
Select-String

don’t have to be in the same directory as it

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

What does the wildcard asterisk mean?

A

selecting all

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

How do you use regular expressions and a command to search for a word in a pattern (entire computer directories)? Provide example

A

Select-String lemonade *.txt

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

How do you quickly change directories to go back to the desktop?

A

cd ..

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What command do you use to search and display a list of patterns within a >specific< directory like D:\Program Files
ls 'D:\Program Files\' -Recurse -Filter *Adobe Recurse to search specific directory Filter filters results for file names that match
26
What command does the -Filter parameter combine with when listing items with patterns and what does it do?
Combines with ls to filter results matching specific patterns
27
What is a similar command to Select-String in Linux?
grep
28
On Linux, what does grep let you search? 4
search for words within files that match a pattern if a certain file exists in a directory if a word was in a file search through multiple files
29
What's an example of a search a word within a text file command on Linux?
grep apple fruit.txt
30
do you have to be in the same directory to search the targeted file using grep? Linux
yes
31
How do you search for a word in multiple files in Linux?
Use the asterisk and grep grep notes *_notes.txt like if the file name was biology_notes.txt math_notes.txt
32
What is echo an alias for?
Write-Output
33
What does the echo command do?
Let's us write the output we want to see (the alias is Write-Output)
34
What can every Windows process and PowerShell command do with input?
produce output using I/O streams or input output streams
35
What are the 3 types of I/O streams?
1. standard input stdin 2. standard output stdout 3. standard error stderr
36
What is a redirect/operator and what is its function? w
A redirect operator lets us change where we want our standard output to go > >>
37
What redirector operator do you use if you only want to add onto a file, not overwrite it? What would it look like?w
You use the double greater than > > -Append command echo relaxed faces > > existingfile.txt (no spaces in the > > brainscape gives me an error when they're together) echo used because we're writing our keyboard input into the output existing file using the > > operator
38
What does the pipe operator look like?
|
39
What are 3 redirect/operators that let us change the standard out?
1. > 2. >> 3. |
40
When would you use ls '(location)' -Recurse -Filter *(search file or word) and cat words.txt | Select-String mi
ls and *wildcard etc is used when searching all directories in a location for a specific pattern (words, file extensions, etc) the pipe operator and Select-String is only searching a specific file for words taken from the output of words.txt
41
What does it mean when you use 2> in regards to a standard error stream? How is it used in a command sequence when trying to remove secure_file?
2> means that you want to redirect the standard error stream to a file instead of the standard output (we won't see it in the CLI) example: rm secure_file 2>error.txt
42
What's a special variable that contains the definition of nothing? A black hole for the purpose of redirection?
$null
43
What variable do you use to filter out error message streams? What's an example of its use when removing a secure_file? Windows
$null rm secure_file 2>$null
44
What's the difference between redirecting the output/error stream using 2> and the pipe | operator?
2> = this is used to filter or redirect error stream messages from the computer system/PowerShell itself (1> would redirect output stream system messages) Pipe | operator = used to redirect output results from a search or command
45
What redirect operator adds onto a file?
>>
46
What redirect operator creates or overwrites a file?
>
47
What number do we use to represent the standard error stream?
2
48
What number do we use to represent the standard output stream?
1
49
If I want to quickly make a text file with some text in it, no programs, what command can I use?
echo sentences > filename
50
You're viewing the contents of Google.txt using ___, what command can you use to search for a word (hotdog) in that document and then create a file (hawdawg.txt) containing the results?
Using cat to view contents of Google.txt cat Google.txt | Select-String hotdog > hawdawg.txt
51
Do you have to be in the same directory as the word you're searching for using sls?
No
52
What does the standard input redirector look like?
< less than
53
What does the standard in redirector do?
Instead of taking input from the keyboard, it uses a file as input
54
In Linux, how do you redirect the error message of some output from a ls?
ls /dir/fake_dir 2> error_output.txt
55
NOW name all 5 redirectors we've learned so far
1. < 2. > 3. >> 4. | 5. 2>
56
What is the Linux version of windows's $null?
/dev/null
57
How would you search to see which subdirectories are in a directory that match a certain word (toast)? Linux
A list of subdirectories that match Toast... ls -la /locationtosearch | grep toast
58
In Bash, what command and 2 flags can be used to view a list of all files in the /home directory?
ls -l -a /home ls -la /home
59
How do you change to another directory that's in the same current directory?
cd ../directoryname in Bash forward slash Windows back slash
60
In Bash, what commands can be used to view the contents of a document? 2
less cat
61
What are 2 ways to search for a word (fruit) in a group of text files? in Bash
grep fruit *.txt grep fruit apple.txt chocolate.txt orange.txt
62
on Linux, we have a directory called /home/ben/Documents, how do we search for the word "important" in the filenames in that specific directory? 2 ways
ls /home/ben/Documents | grep important grep -rw /home/ben/Documents -e "important"
63
on Windows, what command would you use to see the first 10 lines of a file called "more_information.txt"
cat more_information.txt -Head 10
64
Linux. What does adding the flag -l do when added to the ls command?
You can view more details about the files that are listed like ownership and permissions
65
What type of files is the less command suited for? Linux What happens when you use less? What is it similar to?
For large input files, it's similar to cat but opens a program and allows movement within the files (scrolling by Enter, q, etc)
66
How would you create multiple directories at once?
mkdir dir1 dir2 dir3
67
What are 3 parameters that mkdir accepts?
1. -p makes parent directories if they don't exist 2. -m mode used to set permissions of directories when created 3. -v run command in verbose mode
68
What command removes empty directories? What are the directories to be removed referred to as?
rmdir they're referred to as an argument
69
What does the command look like to remove multiple empty directories?
rmdir dir1 dir2 dir3
70
How do you remove non-empty directories?
rm -r
71
What's the only option that rmdir accepts?
-p removes parent directories if they're also empty
72
By default, what does the touch command do? L
creates a new file with default permissions the touch command changes the modification and access times of a file
73
what happens when you use touch for a file that doesn't exist? L
touch command is used to create a file with default permissions touch empty_file
74
what options does the touch command accept? Linux
-c do not create file if it doesn't exist
75
what command lets you create a file with default permissions? L
touch
76
Does cp replace/overwrite existing files with the same name?
yes
77
What happens if you use cp but don't specify a target name?
a copy of the source will be made in the target directory under the same name
78
When using cp, if the target is a directory that doesn't exist, then the source must be a ____
directory a copy of source directory and contents are made in target under same name
79
What does the mv command do?
moves one or more files or directories into a different location also renames them to a new name
80
What does the command look like when moving fish.txt from home/Desktop to home/Desktop/Folder1?
mv fish.txt home/Desktop/Folder1
81
How do you insert a special character space for a file name? Linux What would it look like for /home/user/Movies/Europe Pictures?
/home/user/Movies/Europe\ Pictures needs the space after the escaped backslash
82
What's a shortcut to copy or move files to the current directory that you place? l (takes the place of destination directory filepath)
mv and a dot after navigating to the directory you want to move something to mv /home/user/Images/Vacation .
83
How do you remove a directory with content? L
rm -r non_empty_dir -r tells rm to remove directory with its content recursively
84
What does grep do? L
powerful Linux command searches through files for the occurence of a string that matches a specified pattern
85
What options and flags are accepted by grep? L 6 things
-r search recursively -w match the whole word -n only in line number -e match pattern --include and --exclude (to ex/include files in search) --include-dir and --exclude-dir (to ex/include directories in search)
86
Explain what to search recursively means?
to search in each sub-level
87
How do you open an existing file to edit in nano on Linux?
nano /path/to/existing/file
88
What are some shortcuts for use in editing a text file in nano?
CTRL O to save modifications CTRL X to exit CTRL G get help
89
In the current directory of user/Documents create an empty file called editor_test.txt. Linux.
touch editor_test.txt