1 / 12

Unix Shell

BASH (Bourne Again SHell) Associate Professor Quincy Wu solomon@2012.ipv6.club.tw National Chi Nan University Linux User Group 2012 Summer Training. Unix Shell. In Unix, a shell is a command-line interface which interprets input from users and take corresponding actions. User. Shell.

nusa
Download Presentation

Unix Shell

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. BASH(Bourne Again SHell)Associate Professor Quincy Wusolomon@2012.ipv6.club.twNational Chi Nan UniversityLinux User Group 2012 Summer Training

  2. Unix Shell • In Unix, a shell is a command-line interface which interprets input from users and take corresponding actions. User Shell Operating System Hardware

  3. History of Unix Shells • sh – Bourne shell • written by Stephen Bourne at AT&T as the original Unix command line interpreter • csh – C Shell • History of commands • C-like syntax • tcsh – Turbo C Shell • Enhanced C shell. Allow users to navigate through the history of commands with the arrow keys. • bash – Bourne Again Shell • Same syntax as Bourne shell, combining the advanced features in csh and tcsh. set a=3 set b=4 if ($a == $b) then echo "a is larger" else echo "b is larger" endif

  4. Topics • Command-line interface • Environment variables • Shell script syntax • Login files

  5. Command-Line Interface (CLI) • Basic Commands • I/O re-direction • Pipeline • Wildcard • Filename completion • History • Substitution • Search through the history of commands

  6. Remote Login with PuTTY • Download PuTTY • Connect to ms11.voip.edu.tw (port 3261),or the Linux machine which you just installed.

  7. Basic Commands • date • cal • cal 10 1911 • who • who am i • cat • cat > filename • cat -n • tail • tail -3 • head • wc • ls • ls -l • ls -lt • ls -lR • sort • sort -r • sort -n • sort +3 • grep • grep -v • grep -i • mv • rm

  8. I/O Redirection • cat > a.cpp #include <iostream> using std::cin; using std::cout; using std::endl; main() { int i, j; for (i=1; i<=5; i++) { cin >> j; cout << i << '\t' << j << endl; } return 0; } • cat > a.dat 98 32 45 26 83 ^D • g++ a.cpp -o a.exe • a.exe • a.exe < a.dat • a.exe < b.dat • a.exe < a.dat > a • cat < a

  9. Pipeline • Connect the output of one program to the input of another program without any temporary file. • who > aaa • sort < aaa • who | sort • who | wc -l • who | grep lilykoko | wc

  10. Wildcard Characters • ls • ls a* • ls a? • ls a[0-9] • ls a[135] • rm a*

  11. Filename Completion • Press <TAB> to complete a command or a filename. • ls /bin/sl <TAB> • ls /bin/sleep • When there are multiple choices, press <TAB> will expand to the common prefix, then press <TAB> twice will list all choices. • ls /usr/local/l <TAB>

  12. History of Commands • history • history -20 • alias h=‘history -20’ • !3 • !! • !c • !3:s/cpp/CPP/ • <ESC>-<.>, <ESC>-<_>, !!:$ • Arrow keys (Up, Down, Left, Right) • Ctrl-A, Ctrl-E, Ctrl-K, Ctrl-W, Ctrl-C • <ESC>-<D>, <ESC>-<BackSpace> • Search: Ctrl-R

More Related