co004 projects on operating systems
Download
Skip this Video
Download Presentation
CO004 Projects on Operating Systems

Loading in 2 Seconds...

play fullscreen
1 / 16

CO004 Projects on Operating Systems - PowerPoint PPT Presentation


  • 119 Views
  • Uploaded on

CO004 Projects on Operating Systems. UNIX - Basics 02. Outline. Directory Display a file Input/Output Redirection Pipe. 1. Directory. Absolute directory /home/s 1 0 X 157/program Relative directory: the directory relative to your current working directory

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' CO004 Projects on Operating Systems' - katell-martin


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
outline
Outline
  • Directory
  • Display a file
  • Input/Output Redirection
  • Pipe
1 directory
1. Directory
  • Absolute directory
    • /home/s10X157/program
  • Relative directory: the directory relative to your current working directory
    • E.g., your current working directory: /home/s10X157/
    • Then, you can use “cd ../program”, which is a relative directory.
several directories
Several directories:
  • . current directory
  • .. parent directory
  • ~ home directory of the current user.
    • E.g., [[email protected]] cd ~/program
    • Will change current working directory to / home/s10X0157/program
2 displayfiles
2. DisplayFiles
  • cat (concatenate)
  • tac (display a file in reversing way)
  • nl (display a file with line no.)
  • more (display a file in pages)
  • less (display a file in pages)
  • head
  • tail
slide6
cat
  • Display a file
  • -E :end-of-line is displayed as $;
  • -n :display with line no. ;
  • -T :[tab] is shown as ^I ;
slide7
tac
  • Display a file in reversing way
  • Display the last line first, then the second last line, so on…
slide8
nl
  • display a file with line no.
  • The same as cat - n file
more and less
more

display a file with pages

Press ‘space’ to the next page

Only forward

No backward

less

display a file with pages

Similar to “more”

Allow backward

more and less
head and tail
head [-n number] file

List the first n lines of file

tail [-n number] file

List the last n lines of file

head and tail
slide11
od
  • od -t
  • Display a file in non-text file
  • -t :with various (TYPE), e.g.

c :ASCII

d[size] :decimal display;

o[size] :octal display;

x[size] :hexadecimal display ;

3 redirecting the output
3. Redirecting the Output
  • We use the > symbol to redirect the output of a command.

% cat > list1

pearbananaapple^D {this means press [Ctrl] and [d] to stop}

% cat list1

  • Appending to a file >>

% cat >> list1

peach

grape

orange

^D (Control D to stop)

3 redirecting the input
3. Redirecting the Input
  • Using < you can redirect the input to come from a file

% sort < list1

  • To output the sorted list to a file, type,

% sort < lists > slist

Note that lists and slist should be different.

4 pipes
4. Pipes
  • To see who is on the system with you, type

% who

  • One method to get a sorted list of names is to type,

% who > names.txt

% sort < names.txt

  • We can use pipe to do this

% who | sort

  • will give the same result as above, but quicker and cleaner. To find out how many users are logged on, type

% who | wc -l

wildcards
Wildcards
  • The * wildcard
  • The character * is called a wildcard, and will match against none or more character(s) in a file (or directory) name. For example

% ls list*

This will list all files in the current directory starting with list....

  • Try typing

% ls *list

This will list all files in the current directory ending with ....list

  • The ? wildcard
  • The character ? will match exactly one character.So ?ouse will match files like house and mouse, but not grouse. Try typing

% ls ?list

reference
Reference
  • 鳥哥的 Linux 私房菜 http://linux.vbird.org/
  • UNIX Quick Reference Sheet http://sunsite.utk.edu/UNIX-help/quickref.html
ad