Command Line Kung Fu Bash Scripting.pdf

(742 KB) Pobierz
Command Line Kung Fu
Jason Cannon
Command Line Kung Fu
1.
Your Free Gift
2.
Introduction
3.
Shell History
1.
Run the Last Command as Root
2.
Repeat the Last Command That Started with a given String
3.
Reuse the Second Word (First Argument) from the Previous
Command
4.
Reuse the Last Word (Last Argument) from the Previous Command
5.
Reuse the Nth Word from a Previous Command
6.
Repeat the Previous Command While Substituting a String
7.
Reference a Word of the Current Command and Reuse It
8.
Save a Copy of Your Command Line Session
9.
Find out Which Commands You Use Most Often
10.
Clear Your Shell History
4.
Text Processing and Manipulation
1.
Strip out Comments and Blank Lines
2.
Use Vim to Edit Files over the Network
3.
Display Output in a Table
4.
Grab the Last Word on a Line of Output
5.
View Colorized Output with Less
6.
Preserve Color When Piping to Grep
7.
Append Text to a File Using Sudo
8.
Change the Case of a String
9.
Display Your Command Search Path in a Human Readable Format
10.
Create a Text File from the Command Line without Using an Editor
11.
Display a Block of Text between Two Strings
12.
Delete a Block of Text between Two Strings
13.
Fix Common Typos with Aliases
14.
Sort the Body of Output While Leaving the Header on the First Line
Intact
15.
Remove a Character or set of Characters from a String or Line of
Output
16.
Count the Number of Occurrences of a String
5.
Networking and SSH
1.
Serve Files in the Current Directory via a Web Interface
2.
Mount a Directory from a Remote Server on Your Local Host via
SSH
3.
Get Your Public IP from the Command Line Using Curl
4.
SSH into a Remote System without a Password
5.
Show Open Network Connections
6.
Compare the Differences between a Remote and Local File
7.
Send Email from the Command Line
8.
Send an Email Attachment from the Command Line
9.
Create an SSH Tunnel to Access Remote Resources
10.
Find out Which Programs Are Listening on Which Ports
11.
Use a Different SSH Key for a given Remote Host
12.
Avoid Having to Type Your Username When Connecting via SSH
13.
Simplify Multi-Hop SSH Connections and Transparently Proxy SSH
Connections
14.
Disconnect from a Remote Session and Reconnect at a Later Time,
Picking up Where You Left Off
15.
Configure SSH to Append Domain Names to Host Names Based on a
Pattern
16.
Run a Command Immune to Hangups, Allowing the Job to Run after
You Disconnect
17.
Encrypt Your Web Browsing Data with an SSH SOCKS Proxy
18.
Download a Webpage, HTTP Data, or Use a Web API from the
Command Line
19.
Use Vim to Edit Files over the Network
6.
Shell Scripting
1.
Use a for Loop at the Command Line
2.
Command Substitution
3.
Store Command Line Output as a Variable to Use Later
4.
Read in Input One Line at a Time
5.
Accept User Input and Store It in a Variable
6.
Sum All the Numbers in a given Column of a Text
7.
Automatically Answer Yes to Any Command
7.
System Administration
1.
Display Mounted File Systems in a Tabular Format
2.
Kill All Processes for a given User or Program
3.
Repeat a Command until It Succeeds
4.
Find Who Is Using the Most Disk Space
5.
Find the Files That Are Using the Most Disk Space
6.
List Processes, Sorted by Memory Usage
7.
List Processes, Sorted by CPU Usage
8.
Quickly Tell If You Are on a 32 Bit or 64 Bit System
9.
Generate a Random Password
8.
Files and Directories
1.
Quickly Make a Backup of a File
2.
Quickly Change a File's Extension
3.
Create Backups of Files by Date with Ease
4.
Overwrite the Contents of a File
5.
Empty a File That Is Being Written To
6.
Append a String to a File
7.
Follow a File as It Grows
8.
Watch Multiple Log Files at the Same Time
9.
Delete Empty Directories
10.
Print a List of Files That Contain a given String
11.
An Easy-to-Read Recursive File Listing
12.
View Files and Directories in a Tree Format
13.
Replace a String in Multiple Files
14.
Extract the Nth Line from a File
15.
Convert Text Files from Windows Format to Linux Format and Vice-
Versa
9.
Miscellaneous
1.
Change to the Previous Working Directory
2.
Reset Your Terminal Emulator Display
3.
Search Wikipedia from the Command Line
4.
Make Non-Interactive Shell Sessions Behave the Same as Interactive
Sessions
5.
Make Your Computer to Talk to You
6.
Display the Current Date and Time in a Different Time Zone
7.
Display a Calendar at the Command Line
8.
Extract a Tar Archive to a Different Directory
9.
Transform the Directory Structure of a Tar File When Extracting It
10.
Use a Spreadsheet from the Command Line
11.
Rudimentary Command Line Stopwatch
12.
Repeat a Command at Regular Intervals and Watch Its Changing
Output
13.
Execute a Command at a given Time
14.
Share Your Screen Session with Another User
15.
Execute an Unaliased Version of an Aliased Command
Zgłoś jeśli naruszono regulamin