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
Q

What command do you use to search and display a list of patterns within a >specific< directory like D:\Program Files

A

ls ‘D:\Program Files' -Recurse -Filter *Adobe

Recurse to search specific directory
Filter filters results for file names that match

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

What command does the -Filter parameter combine with when listing items with patterns and what does it do?

A

Combines with ls to filter results matching specific patterns

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

What is a similar command to Select-String in Linux?

A

grep

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

On Linux, what does grep let you search? 4

A

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

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

What’s an example of a search a word within a text file command on Linux?

A

grep apple fruit.txt

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

do you have to be in the same directory to search the targeted file using grep? Linux

A

yes

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

How do you search for a word in multiple files in Linux?

A

Use the asterisk and grep

grep notes *_notes.txt

like if the file name was biology_notes.txt
math_notes.txt

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

What is echo an alias for?

A

Write-Output

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

What does the echo command do?

A

Let’s us write the output we want to see (the alias is Write-Output)

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

What can every Windows process and PowerShell command do with input?

A

produce output using I/O streams or input output streams

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

What are the 3 types of I/O streams?

A
  1. standard input stdin
  2. standard output stdout
  3. standard error stderr
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

What is a redirect/operator and what is its function? w

A

A redirect operator lets us change where we want our standard output to go

> >

37
Q

What redirector operator do you use if you only want to add onto a file, not overwrite it? What would it look like?w

A

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
Q

What does the pipe operator look like?

A

|

39
Q

What are 3 redirect/operators that let us change the standard out?

A
  1. >
  2. > >
  3. |
40
Q

When would you use ls ‘(location)’ -Recurse -Filter *(search file or word)
and
cat words.txt | Select-String mi

A

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
Q

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?

A

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
Q

What’s a special variable that contains the definition of nothing? A black hole for the purpose of redirection?

A

$null

43
Q

What variable do you use to filter out error message streams? What’s an example of its use when removing a secure_file? Windows

A

$null

rm secure_file 2>$null

44
Q

What’s the difference between redirecting the output/error stream using 2> and the pipe | operator?

A

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
Q

What redirect operator adds onto a file?

A

> >

46
Q

What redirect operator creates or overwrites a file?

A

>

47
Q

What number do we use to represent the standard error stream?

A

2

48
Q

What number do we use to represent the standard output stream?

A

1

49
Q

If I want to quickly make a text file with some text in it, no programs, what command can I use?

A

echo sentences > filename

50
Q

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?

A

Using cat to view contents of Google.txt

cat Google.txt | Select-String hotdog > hawdawg.txt

51
Q

Do you have to be in the same directory as the word you’re searching for using sls?

A

No

52
Q

What does the standard input redirector look like?

A

<

less than

53
Q

What does the standard in redirector do?

A

Instead of taking input from the keyboard, it uses a file as input

54
Q

In Linux, how do you redirect the error message of some output from a ls?

A

ls /dir/fake_dir 2> error_output.txt

55
Q

NOW name all 5 redirectors we’ve learned so far

A
  1. <
  2. >
  3. > >
  4. |
  5. 2>
56
Q

What is the Linux version of windows’s $null?

A

/dev/null

57
Q

How would you search to see which subdirectories are in a directory that match a certain word (toast)? Linux

A

A list of subdirectories that match Toast…

ls -la /locationtosearch | grep toast

58
Q

In Bash, what command and 2 flags can be used to view a list of all files in the /home directory?

A

ls -l -a /home
ls -la /home

59
Q

How do you change to another directory that’s in the same current directory?

A

cd ../directoryname

in Bash forward slash
Windows back slash

60
Q

In Bash, what commands can be used to view the contents of a document? 2

A

less
cat

61
Q

What are 2 ways to search for a word (fruit) in a group of text files? in Bash

A

grep fruit *.txt

grep fruit apple.txt chocolate.txt orange.txt

62
Q

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

A

ls /home/ben/Documents | grep important

grep -rw /home/ben/Documents -e “important”

63
Q

on Windows, what command would you use to see the first 10 lines of a file called “more_information.txt”

A

cat more_information.txt -Head 10

64
Q

Linux. What does adding the flag -l do when added to the ls command?

A

You can view more details about the files that are listed like ownership and permissions

65
Q

What type of files is the less command suited for? Linux What happens when you use less? What is it similar to?

A

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
Q

How would you create multiple directories at once?

A

mkdir dir1 dir2 dir3

67
Q

What are 3 parameters that mkdir accepts?

A
  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
Q

What command removes empty directories? What are the directories to be removed referred to as?

A

rmdir

they’re referred to as an argument

69
Q

What does the command look like to remove multiple empty directories?

A

rmdir dir1 dir2 dir3

70
Q

How do you remove non-empty directories?

A

rm -r

71
Q

What’s the only option that rmdir accepts?

A

-p removes parent directories if they’re also empty

72
Q

By default, what does the touch command do? L

A

creates a new file with default permissions

the touch command changes the modification and access times of a file

73
Q

what happens when you use touch for a file that doesn’t exist? L

A

touch command is used to create a file with default permissions

touch empty_file

74
Q

what options does the touch command accept? Linux

A

-c do not create file if it doesn’t exist

75
Q

what command lets you create a file with default permissions? L

A

touch

76
Q

Does cp replace/overwrite existing files with the same name?

A

yes

77
Q

What happens if you use cp but don’t specify a target name?

A

a copy of the source will be made in the target directory under the same name

78
Q

When using cp, if the target is a directory that doesn’t exist, then the source must be a ____

A

directory

a copy of source directory and contents are made in target under same name

79
Q

What does the mv command do?

A

moves one or more files or directories into a different location

also renames them to a new name

80
Q

What does the command look like when moving fish.txt from home/Desktop to home/Desktop/Folder1?

A

mv fish.txt home/Desktop/Folder1

81
Q

How do you insert a special character space for a file name? Linux What would it look like for /home/user/Movies/Europe Pictures?

A

/home/user/Movies/Europe\ Pictures

needs the space after the escaped backslash

82
Q

What’s a shortcut to copy or move files to the current directory that you place? l

(takes the place of destination directory filepath)

A

mv and a dot after navigating to the directory you want to move something to

mv /home/user/Images/Vacation .

83
Q

How do you remove a directory with content? L

A

rm -r non_empty_dir

-r tells rm to remove directory with its content recursively

84
Q

What does grep do? L

A

powerful Linux command

searches through files for the occurence of a string that matches a specified pattern

85
Q

What options and flags are accepted by grep? L 6 things

A

-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
Q

Explain what to search recursively means?

A

to search in each sub-level

87
Q

How do you open an existing file to edit in nano on Linux?

A

nano /path/to/existing/file

88
Q

What are some shortcuts for use in editing a text file in nano?

A

CTRL O to save modifications
CTRL X to exit
CTRL G get help

89
Q

In the current directory of user/Documents create an empty file called editor_test.txt. Linux.

A

touch editor_test.txt