Using Bash Shell. Command Line Shortcuts File Globbing Globbing is wildcard expansion: * - matches zero or more characters ? - matches any single character.

Презентация:



Advertisements
Похожие презентации
Week Configuring the Bash Shell 2 Environment Variables Bash variables are local to a single shell by default Set with VARIABLE= VALUE Environment.
Advertisements

Browsing the Filesystem. Linux File Hierarchy Concepts Files and directories are organized into a single- rooted inverted tree structure Filesystem begins.
Standard I/O and Pipes. Standard Input and Output Linux provides three I/O channels to Programs Standard input (STDIN) - keyboard by default Standard.
Week Finding and Processing files 2 locate Queries a pre-built database of paths to files on the system Database must be updated by administrator.
© 2005 Cisco Systems, Inc. All rights reserved. BGP v Route Selection Using Policy Controls Employing AS-Path Filters.
Unit 2 Users Management. Users Every user is assigned a unique User ID number (UID) UID 0 identifies root User accounts normally start at UID 500 Users'
Unit 3 Text Processing and System Configuration tools.
Basic Input - Output. Output functions printf() – is a library function that displays information on-screen. The statement can display a simple text message.
© 2009 Avaya Inc. All rights reserved.1 Chapter Two, Voic Pro Components Module Two – Actions, Variables & Conditions.
© 2005 Cisco Systems, Inc. All rights reserved.INTRO v Managing Your Network Environment Managing Cisco Devices.
© 2005 Cisco Systems, Inc. All rights reserved. BGP v Route Selection Using Policy Controls Applying Route-Maps as BGP Filters.
Using Dreamweaver MX Slide 1 Window menu Manage Sites… Window menu Manage Sites… 2 2 Open Dreamweaver 1 1 Set up a website folder (1). Click New…
S4-1 PAT328, Section 4, September 2004 Copyright 2004 MSC.Software Corporation SECTION 4 FIELD IMPORT AND EXPORT.
SPLAY TREE The basic idea of the splay tree is that every time a node is accessed, it is pushed to the root by a series of tree rotations. This series.
Running Commands & Getting Help. Running Commands Commands have the following syntax: command options arguments Each item is separated by a space Options.
DRAFTING TECHNIQUES II 155. Auxiliary Views Auxiliary Views are easily made. When more specific detail of a part is needed, go to the VIEWS toolbar, then.
Date: File:GRAPH_02e.1 SIMATIC S7 Siemens AG All rights reserved. SITRAIN Training for Automation and Drives Project Planning and Configuration.
PAT312, Section 21, December 2006 S21-1 Copyright 2007 MSC.Software Corporation SECTION 21 GROUPS.
Overview of the Paysonnel CE. Overview Paysonnel CE Go to URL- 1 Click [Login to Paysonnel CE] 2 How to Log-in to Paysonnel CE 1 2.
S5-1 PAT328, Section 5, September 2004 Copyright 2004 MSC.Software Corporation SECTION 5 RESULTS TITLE EDITOR.
Транксрипт:

Using Bash Shell

Command Line Shortcuts File Globbing Globbing is wildcard expansion: * - matches zero or more characters ? - matches any single character [0-9] - matches a range of numbers [abc] - matches any of the character in the list [^abc] - matches all except the characters in the list Predefined character classes can be used

The Tab Key Type Tab to complete command lines: For the command name, it will complete a command name For an argument, it will complete a file name Examples: $ xte $ xterm $ ls myf $ ls myfile.txt

Command Line Shortcuts History bash stores a history of commands you've entered, which can be used to repeat commands Use history command to see list of "remembered" commands $ history 14 cd /tmp 15 ls -l 16 cd 17 cp /etc/passwd. 18 vi passwd... output truncated... More History Tricks Use the up and down keys to scroll through previous commands Type Ctrl-r to search for a command in command history. (reverse-i-search)`': To recall last argument from previous command: Esc,. (the escape key followed by a period) Alt-. (hold down the alt key while pressing the period) !$ (only valid for the last command)

Command Line Expansion The tilde Tilde ( ~ ) May refer to your home directory $ cat ~/.bash_profile May refer to another user's home directory $ ls ~julie/public_html Commands and Braced Sets Command Expansion: $() or `` Prints output of one command as an argument to another $ echo "This system's name is $(hostname)" This system's name is server1.example.com Brace Expansion: { } Shorthand for printing repetitive strings $ echo file{1,3,5} file1 file3 file5 $ rm -f file{1,3,5}

Bash Variables Variables are named values Useful for storing data or command output Set with VARIABLE=VALUE Referenced with $VARIABLE $ HI="Hello, and welcome to $(hostname)." $ echo $HI Hello, and welcome to stationX.

Command Editing Tricks Ctrl-a moves to beginning of line Ctrl-e moves to end of line Ctrl-u deletes to beginning of line Ctrl-k deletes to end of line Ctrl-arrow moves left or right by word

gnome-terminal Applications->Accessories->Terminal Graphical terminal emulator that supports multiple "tabbed" shells Ctrl-Shift-t creates a new tab Ctrl-PgUp/PgDn switches to next/prev tab Ctrl-Shift-c copies selected text Ctrl-Shift-v pastes text to the prompt Shift-PgUp/PgDn scrolls up and down a screen at a time

Scripting Basics Shell scripts are text files that contain a series of commands or statements to be executed. Shell scripts are useful for: Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts Step 1: Create a text file containing commands First line contains the magic shebang sequence: #! #!/bin/bash Comment your scripts! Comments start with a # Step 2: Make the script executable: $ chmod u+x myscript.sh To execute the new script: Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script #!/bin/bash # This script displays some information about you r environment echo "Greetings. The date and time are $(date)" echo "Your working directory is: $(pwd)"