printf("Hello, world.\n");"> printf("Hello, world.\n");">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Command Line, Part II, Pine, and Pico CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture.

Similar presentations


Presentation on theme: "The Command Line, Part II, Pine, and Pico CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture."— Presentation transcript:

1 The Command Line, Part II, Pine, and Pico CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.

2 wc (Word Count) The wc command tells us some additional size-related statistics about the file. The wc command tells us some additional size-related statistics about the file. ls displays the size of the file in bytes ls displays the size of the file in bytes wc displays the number of lines and number of words (as well as bytes) wc displays the number of lines and number of words (as well as bytes) Arguments: -c (# bytes), -l (# newlines), -m (# characters), -w (# words) Arguments: -c (# bytes), -l (# newlines), -m (# characters), -w (# words) Example using a single file as the argument: Example using a single file as the argument: linux1-(10:48am): wc file1.txt 803593717file1.txt 803593717file1.txt Example using multiple files as arguments, separated by spaces. When we switch over to multiple files, wc also reports the grand total. Example using multiple files as arguments, separated by spaces. When we switch over to multiple files, wc also reports the grand total. linux1-(10:48am): wc file1.txt hello.c 803593717file1.txt 803593717file1.txt 20 74 596hello.c 20 74 596hello.c 1004334313total Example using multiple files as arguments, using a wildcard: Example using multiple files as arguments, using a wildcard: linux1-(10:49am): wc *.txt 80 3593717file1.txt 80 3593717file1.txt 63 3502592file2.txt 63 3502592file2.txt 63 3502592file3.txt 63 3502592file3.txt 20610598901total

3 diff (the DIFFerence between two files) In this example, there are two C source code files. There is a slight difference between the 2 files. We will show the contents of each first then use the diff command and let it spot the difference. In this example, there are two C source code files. There is a slight difference between the 2 files. We will show the contents of each first then use the diff command and let it spot the difference. linux1-(10:55am): cat foo.c /* File: hello.c * Description: This program prints the message "Hello, world.“ * Description: This program prints the message "Hello, world.“ */ */ #include #include int main() { printf("Hello, world.\n") return 0; } linux1-(10:55am): cat bar.c /* File: hello.c * Description: This program prints the message "Hello, world.“ * Description: This program prints the message "Hello, world.“ */ */ #include #include int main() { printf("Hello, world.\n"); return 0; } linux1-(10:55am): diff foo.c bar.c 18c18 <printf("Hello, world.\n") --- >printf("Hello, world.\n");

4 The UNIX Pipe (|) The pipe (|) creates a channel from one command to another. Think of the pipe as a way of connecting the output from one command to the input of another command. The pipe (|) creates a channel from one command to another. Think of the pipe as a way of connecting the output from one command to the input of another command. The pipe can be used to link commands together to perform more complex tasks that would otherwise take multiple steps (and possibly writing information to disk). The pipe can be used to link commands together to perform more complex tasks that would otherwise take multiple steps (and possibly writing information to disk). Examples: Examples: Count the number of users logged onto the current system. Count the number of users logged onto the current system. The who command will give us line by line output of all the current users. The who command will give us line by line output of all the current users. We could then use the wc -l to count the number of lines... We could then use the wc -l to count the number of lines... who | wc –l who | wc –l Display long listings in a scrollable page. Display long listings in a scrollable page. The lpq command will give us a list of the waiting print jobs. The lpq command will give us a list of the waiting print jobs. lpq | less lpq | less

5 sort (SORTs lines of text files) sort arranges lines alphabetically (or numerically with the –n option) sort arranges lines alphabetically (or numerically with the –n option) Example: Example: Display a sorted list of all users on the computer. Display a sorted list of all users on the computer. who | sort | less who | sort | less Display a list of files sorted in decreasing order by size in bytes Display a list of files sorted in decreasing order by size in bytes wc -c * | sort -nr wc -c * | sort -nr Other commands which are useful with sort: Other commands which are useful with sort: uniq : removes duplicate adjacent lines from a file uniq : removes duplicate adjacent lines from a file Example: sort file.txt | uniq Example: sort file.txt | uniq cat -n : prepends line numbers cat -n : prepends line numbers Example : sort file.txt | cat -n Example : sort file.txt | cat -n

6 pine (Program for Internet News and E-mail) Pine is the University of Washington's "Program for Internet News and Email". Pine is the University of Washington's "Program for Internet News and Email". It is intended to be an easy-to-use program for sending, receiving, and filing Internet electronic mail messages and bulletin board (Netnews/Usenet) messages. It is intended to be an easy-to-use program for sending, receiving, and filing Internet electronic mail messages and bulletin board (Netnews/Usenet) messages. Pine Help: Help can be accessed anytime by typing the question mark character (?). Pine Help: Help can be accessed anytime by typing the question mark character (?). Links for more information about pine: Links for more information about pine: Official Pine Website: http://www.washington.edu/pine/ Official Pine Website: http://www.washington.edu/pine/http://www.washington.edu/pine/ Pine Tutorial: http://www.washington.edu/pine/tutorial/ Pine Tutorial: http://www.washington.edu/pine/tutorial/http://www.washington.edu/pine/tutorial/ Pine Users Guide: http://www.washington.edu/pine/user- guide/ Pine Users Guide: http://www.washington.edu/pine/user- guide/http://www.washington.edu/pine/user- guide/http://www.washington.edu/pine/user- guide/

7 Pine Commands GENERAL – general navigation – general navigation ? – help READING MAIL r – reply f – forward s – save a message to another mail folder e – export the message to a text file COMPOSING MAIL ^r – insert file contents ^t – to files ^x – send message ^o – postpone message ^c – cancel message ^j – justify (while in header) or attach (while in body) ^k – cut line ^u – uncut line

8 Pico Pico is an easy-to-use editor that resembles Pine. Pico is an easy-to-use editor that resembles Pine. Think of it as a simplified version of emacs. Think of it as a simplified version of emacs. Although it lacks most of emacs' sophisticated functions, pico compensates by having virtually no learning curve associated with its use. Although it lacks most of emacs' sophisticated functions, pico compensates by having virtually no learning curve associated with its use. Unlike emacs, pico is a shell or terminal-based editor only. Unlike emacs, pico is a shell or terminal-based editor only. There are no added benefits of running pico under X window. There are no added benefits of running pico under X window. There is no toolbar, but pico always displays a list of commands at the bottom of the screen. There is no toolbar, but pico always displays a list of commands at the bottom of the screen. Pico does not have as extensive of a tutorial as EMACS, but it does offer a built in help screen. To access it type ctrl-g. Pico does not have as extensive of a tutorial as EMACS, but it does offer a built in help screen. To access it type ctrl-g. Pico - Reference Card: Pico - Reference Card: http://www.cs.umbc.edu/~cshc/resources/new_student/pico_BASICS.sht ml http://www.cs.umbc.edu/~cshc/resources/new_student/pico_BASICS.sht ml

9 Pico Commands ^G - Display help. ^X - Exit pico, saving buffer. ^O - Saves the current buffer to a file. ^^ - Mark cursor position as beginning of selected text. ^K - Cut selected text. Note: The selected text's boundary on the cursor side ends at the left edge of the cursor. ^U - Paste last cut text at the current position. ^W - Search for text. ^T - Invoke the spelling checker. ^L - Refresh the display. ^J - Format (justify) the current paragraph. ^V - Move forward a page of text. ^Y - Move backward a page of text. ^F - Move forward a character. ^B - Move backward a character. ^P - Move to the previous line. ^N - Move to the next line. ^A - Move to the beginning of the current line. ^E - Move to the end of the current line. ^C - Report current cursor position. ^D - Delete the character at the cursor. ^I - Insert a tab at the cursor. ^R - Insert an external file at the cursor.


Download ppt "The Command Line, Part II, Pine, and Pico CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture."

Similar presentations


Ads by Google