Unix and Linux - 4
produces output optimized for visually (interactively) comparing two files.
sdiff
VI's ___ Mode is normal typing mode
Insert
What is grep used for?
grep reads a file line-by-line looking for a string you specify. It prints the lines in which it finds the string.
Mode in which you can enter instructions to VI such as undo, cut-and-paste, and save.
Command
The editor VI has two modes of operation
Command and Insert
Command Mode has two forms:
Single key and last line
Which is the proper grep command for searching a file?
The command comes first on the command line, all the parameters follow after it. grep searchString filename
grep is case sensitive by default. How do you make it case insensitive?
To make grep case insensitive, use the -i option, which goes right after the command. • The command comes first. • The options (or flags) follow right after the command. • Arguments, such as search strings & file names, are last. grep -i searchString filename
History prints the last hundred or so commands you entered at the command prompt. grep nano searches for all the lines that contain the string "nano". How would you combine these to find only the times you entered nano at the command line?
To pass the output from one command to the input of another, use the pipe | operator. history | grep nano
What's the proper grep command for searching the output of another command instead of searching a file?
Use the pipe symbol to send the output of one command to the input of grep. cat filename | grep searchString
produces output intended to be read by another program, usually patch.
diff
To make a patch use:
diff • diff -u originalFile changedFile > patchFile
To examine the permissions, letters on the lefthand side of the display, (such as "executable") of a file, use this command:
ls -l
To apply a patch use:
patch • patch < patchFile
To undo a patch if you change your mind. The name of the file to be undone is coded in the patch file.
patch -R < patchFile
A script file has all of these characteristics:
• It's a text file you write using a text editor. • It's a file of commands you want to re-run. • It's executable - You have to use chmod to make it executable.