1 / 16

Day 3

Day 3. Review The Shell Additional Commands. Things to Review. Lets spend some time going over questions from the last class. Ask about any Unix command you don’t understand Concepts you have never seen before. We will try to get everyone to a level playing field. What is a shell?.

neorah
Download Presentation

Day 3

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. Day 3 Review The Shell Additional Commands

  2. Things to Review • Lets spend some time going over questions from the last class. • Ask about any Unix command you don’t understand • Concepts you have never seen before. • We will try to get everyone to a level playing field.

  3. What is a shell? • Basically a command interpreter • Runs programs • Returns output • Allows you to write shell scripts to automate things • Many different shells • bash • c-shell • zsh

  4. Tab Complete • Makes life much easier. • Less error prone • Faster • Will complete file names, or commands. • Its smart enough to know what its trying to complete. • Also handy if you just don’t remember what you are looking for when you are running a command.

  5. Previous commands • Up/Down arrows recall previous commands • You can also use: • !ls • To recall the last time you used a command starting with ls • !tar • For example will recall the last rpm command which might have been • tar cvf all.tar a.txt b.txt c*

  6. Editing previous command lines • You can also set your shell to use your favorite VI commands. • set -o vi • Will make the shell use the VI editor for command line editing. • This allows you to recall last commands with • [Esc] k • or to edit a command line to delete a word or to do other vi things.

  7. Shell Startup • Each shell is started by executing the program /etc/profile • Users can modify their environment by changing .bash_profile • For example if you liked what we just did to make vi your editor on the command line, you could put that into your .bash_profile.

  8. aliases • An alias can be used to make more friendly commands for things which you always forget: • In dos you use dir, in Unix you use ls. • What if you want to be able to type dir in Unix, and have it work the same: • alias dir=ls • sometimes its hard to remember how to use tar: • alias untar=“tar xvf” • Now you can: • untar file.tar

  9. Environment Variables • Type the command: • set • To see a list of all variables set in your shell • This includes your PATH and others. • You can modify these directly or change them in your .bash_profile, so they will always be what you set them to.

  10. export • Children don’t see environment variables unless they are exported. • Each shell has its own environment.

  11. Sed • Sed is a very handy command for editing a text file. • VI can edit a text file, but you can’t use vi in a script. It requires human interaction • sed allows you to do what vi can do, directly from the command line: • sed ‘s/a/b/’ myfile • Would open myfile, look for all occurrences of the letter a, replace it with the letter b, and output the new file to the screen.

  12. 3 Input/Output channels. • Standard In (0) • Typically this is your keyboard • Standard Out (1) • Typically this is your screen • Standard Error (2) • Typically this is your screen also.

  13. Each can be redirected. • command < input.file • command > output.file • command 2> error.file • command > all.output 2>&1 • command >> appended.file

  14. Pipes • Any commands output can be piped into another process. • There is no limit to the number of pipes you can output • ps –auwx | awk ‘{print $1}’ | sort | uniq > output

  15. Find • Lost a file? • find / -name ‘enda.txt’ –print • Most systems understand the –print by default.

  16. Using VI • Good idea to know. • Not all systems have Joe/Emacs/etc installed. • They all have vi. • Slow to learn, but very powerful later. • Learn the basics we’ll get to the advanced stuff later.

More Related