Searching in files and using Pipes Flashcards

1
Q

To look for text within a file use this command:

A

grep ex: grep pattern file (pattern is what you are looking for in the file)

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

grep options are:

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

Searching files using some of the following commands. Also you can chain them together to do something really useful

A

grep pattern file , ex: grep -i User files.txt

file file_name , shows you the file type, ex: file sales.data

strings, lets you see text that’s in a binary format

cut, allows you to cut out portions of a file / ex: cut -d’ ‘ -f2
cut options:
-d delimeter / use as a field separator
-f N displays the ninth field

tr or translate (changes output to something else) ex: tr “:” “ “

column / ex: column -t ( puts output in a table format)

more

less

or the pipe command allows you to tie 2 command together, ex: cat files.txt | more ( you can chain as many command together as you want )

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

If you want to copy files from your desktop to a linux server or from server to server you would use these commands:

“Are also part of the Secure Shell Protocol”

A

scp - Secure Copy
sftp - SSH file transfer protocol

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

Examples of Command line SCP Clients include:

A

scp
sftp
Putty Secure Copy Client - pscp.exe
Putty Secure File Transfer client - psftp.exe

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

Some Graphical SCP/SFTP Clients include:

A

Cyberduck - Mac / Windows
FileZilla - Mac / Windows / and Linux
WinsSCP - Windows only

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

To customize your Shell Prompt, use an:

A

Environment Variable
Bash, ksh, and sh use $PS
Csh, tcsh, and zsh use $prompt

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

Customizing the Shell Prompt with Bash (most popular) PS1:

For a complete listing of all the formatting option, see the “bash” man page

A

\d - Dante in “Weekday Month Date” format ( TueMay26 )
\h - Hostname up to the first period
\H - Hostname
\n - Newline
\t - Current time in 24 hour HH:MM:SS format
\T - Current time in 12 hour HH:MM:SS format

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

To make the changes persist between logins, use this Environment variable in your dot files;
“ You can also use Nano, Vi, or emacs to edit this file”

A

$ echo ‘export PS1=” [ \u@\h \w] $ “ ‘&raquo_space; ~/ .bash_proflie

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

Aliases are mainly used for:

A

Shortcuts
Use for long commands
Commands you type often

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

To view the list of alias’s already set, use this command

A

alias

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

aliases can also fix typos:
Make Linux behave like another OS:

A

$ alias grpe=’grep’
$ alias cls=’clear’

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

To remove Aliases:

A

unalias name / Remove the “name” alias
unalias -a / Remove all aliases

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

So your aliases persist / continue:

A

Add them to your .dot files
.bash_profile

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