Lecture5 - CSIS 4840 Week 5 Shells Prof Ron...

Info icon This preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon
CSIS 4840: Week 5 Shells Prof. Ron Schnell (“Ron”) @RonnieSchnell
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008 Chapter 9: Exploring the Shell 2 of 30
Image of page 2
Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008 Chapter 9: Exploring the Shell 3 of 30
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008 Chapter 9: Exploring the Shell 4 of 30 + csh (“C Shell”) & tcsh (“TC Shell”) have all of these features built-in
Image of page 4
Review of Shell Expansion Review: arguments with special characters will be expanded by all of the shells before it runs the program (unless surrounded by single quotes) $ echo *txt foo.txt mytxt txt $ echo ??txt mytxt $ echo *.?xt foo.txt Different shells behave differently when there is no match for wildcards: sh and bash : Will pass the argument with the
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Review of Shell Expansion (cont’d) In addition to * and ? bash, csh, and tcsh expand
Image of page 6
More Shell Expansion !! expands to the entire previous command $ !! rm /etc/passwd rm: permission denied $ sudo !! !-<n> goes back n commands ( !-3, !- 5, etc.) !$ expands to the last argument of the previous command: $ ls /etc/passwd
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
More Shell Expansion (cont’d) !* is all of the arguments $ ls foo bar bletch foo bar bletch $ rm !* rm foo bar bletch Command history search with !? $ history 1 pwd 2 cd /home/student 3 ls *.txt 4 cat < /etc/motd $ !?cd cd /home/student !?cd? would also work
Image of page 8
Command Line Editing (bash, csh, and tcsh) Follow a command history expansion with a colon ( : ) followed by a standard ed command $ !!:p ls /home/student This does not run the command, just prints it, but it also gets put into history as the last command $ !!:s/student/ronnie/ ls /home/ronnie This does run the command with the changes $ !?ls?:s/ronnie/student/
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Command Line Editing (bash, csh, and tcsh) Put a number after the colon (line a line number in ed ) to represent an argument number $ cd !ls:1 cd /home/student $ echo ls ls $ !!:1 ls foo bar
Image of page 10
Command Line Editing (ksh) To search using ksh use the r key $ r ls ls /home/student To rerun a command using ksh by its history number, also use the r key $ r 103 pwd /home/ronnie
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Visual Command Line Editing (bash, ksh, and tcsh) bash, ksh, and tcsh allow you to edit the command line in place , and each has a mode for vi and emacs bash and tcsh are in emacs mode by default, while ksh is in vi mode by default Changing mode for bash and ksh : $ set -o vi # vi mode $ set -o emacs # emacs mode Changing mode for tcsh: $ bindkey -v # vi mode $ bindkey -e # emacs mode
Image of page 12
Visual Command Line Editing (bash, ksh, and tcsh) In vi mode, you can begin editing the command line visually by pressing the ESCAPE key (just like in vi) Non-colon vi commands work, including h,j,k,l to move around command history.
Image of page 13

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern