4-Creating, Viewing, and Editing Text Files

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

pipeline

Allows the output of a process to be manipulated and formatted by other processes before it's output to the terminal.

Vim

An improved version of the vi editor distributed with Linux and UNIX systems.

find /etc -name passwd >> /tmp/save-both 2>&1

Append output and generated errors to an existing file

echo "new line of info" >> /tmp/many-lines-of-info

Append output to an existing file

cat file1 file2 file3 file4 > /tmp/all-four-in-one

Concatenate four files into one

pipe

Connects the standard output of the first command to the standard input of the next command.

tail -n 100 /var/log/dmesg > /tmp/last-100-boot-messages

Copy the last 100 lines from a log file to another file

ls | wc -l

Count the number of lines from an ls command.

find /etc -name passwd > /tmp/output 2> /dev/null

Ignore and discard error messages while capturing stdout to file

tee

In a pipeline, this command will copy it's standard input to its standard output and will also redirect it's standard output to the files named as args to the command.

ls -a > /tmp/my-file-names

List a home directory's hidden and regular file names into a file

command mode

Mode of operation Vim opens in, used for navigation, cut and paste, and other text manipulation.

file descriptors

Numbered channels used by processes to get input and send output.

date > /tmp/saved-timestamp

Save a timestamp for later reference

find /etc -name passwd 2> /tmp/errors

Save error messages to file

find /etc -name passwd > /tmp/output 2> /tmp/errors

Save process output and error messages to different files

find /etc -name passwd &> /tmp/save-both

Store output and generated errors together

ls -l /usr/bin | less

Take the output of the ls command and use less to display it on the terminal one screen at a time.

i

This Vim hotkey enters insert mode, where all typed text becomes file content. Pressing Esc returns to command mode

v OR V for multi-line or Ctrl+v for block selection

This Vim hotkey enters visual mode, where multiple multiple characters can be selected for text manipulation. The same character exits visual mode.

stdin - Standard input

This file descriptor uses channel 0, Default connection of Keyboard, and it's usage is read only.

stdout - Standard output

This file descriptor uses channel 1, Default connection of Terminal, and it's usage is write only.

stderr - Standard error

This file descriptor uses channel 2, Default connection of Terminal, and it's usage is write only

filename - Other files

This file descriptor uses channels 3+, Default connection of none, and it's usage is read and/or write

2>/dev/null

discard stderr error messages by redirecting to /dev/null

2>file

redirect stderr to overwrite a file

>>file 2>%1 OR %>>file

redirect stdout and stderr to append to the same file

>file 2>%1 OR %>file

redirect stdout and stderr to overwrite the same file

>>file

redirect stdout to append to a file

>file

redirect stdout to overwrite a file

ls -t | head -n 10 > /tmp/ten-last-changed-files

save first 10 lines of ls -t command to a file

y - yank

Vim copy command

p - put

Vim paste command

x

Vim: deletion of text in command mode

:q!

Vim: quit vim, and discard all file changes since the last write.

u

Vim: undo changes on current line

:w

Vim: write (save) the file and remain in command mode for more editing

:wq

Vim: write the file and quit Vim


संबंधित स्टडी सेट्स

Chapter 42: Structure and Function of the Male Genitourinary System

View Set

FUNDAMENTALS EXAM 3 PRACTICE QUESTIONS

View Set

IEM Economics (2nd Edition) Unit 1, Lesson 3 - Traditional and Command

View Set

Module 16: Mood Disorders and Suicide

View Set

BLAW 2 Final - Reasonable Accommodations - Little

View Set