Introduction to Unix (CA263) Unix/Linux Utilities - PowerPoint PPT Presentation

About This Presentation
Title:

Introduction to Unix (CA263) Unix/Linux Utilities

Description:

jay. pat. kit. sam. joe. Page 67. diff. diff file1 file2 sign indicates file1 ... jay. 2a2 kit. Page 67. Regular ... Color: blue. Page 72 ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 28
Provided by: til46
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Unix (CA263) Unix/Linux Utilities


1
Introduction to Unix (CA263) Unix/Linux
Utilities
  • By
  • Tariq Ibn Aziz

2
Objectives
  • Check File Type
  • Unix utilities more, less, head, tail command
  • Check Spelling
  • Splitting a File
  • comm and diff command
  • Regular Expression rules
  • grep and egrep Printing Files
  • PostScript and PDF Files
  • Encrypting and Decrypting a File
  • mpage versus enscript

3
Check File Type
  • Unixgt file .login
  • .login assembler program text
  • (Page 28)

4
more or less
  • Less is an improved version of more command.
  • You can say that more is less than less, and less
    is more than more.
  • (Page 62)

5
head or tail
  • head view lines at the beginning of a file, by
    default, it display 10 line from top
  • tail view lines at the end of a file, by
    default, it display 10 line from bottom
  • (Page 63)

6
Check Spelling
  • Unixgt spell info.txt
  • Username
  • dis
  • For interactive spell checking use ispell. For
    more information see man ispell
  • (page 64)

7
Split a File
  • Unixgt vi data.txt
  • Username
  • Tariq
  • Naif
  • Musa
  • Manea
  • Hassan
  • Monim
  • To split data file into files with 2 line each.
  • Unixgt split -2 data.txt stuff
  • unixgt ls stuff
  • Stuffaa stuffab stuffac stuffad

Page 66
8
comm
  • comm is very handy command.
  • comm file1 file2 will report three column report.
  • Unique lines in f.txt, unique lines in g.txt, and
    duplicate lines
  • unixgt comm f.txt g.txt
  • jay
  • pat
  • kit
  • sam
  • joe

Page 67
9
diff
  • diff file1 file2
  • lt sign indicates file1
  • gt sign indicates file2
  • 1d0 is number-letter-number
  • 1 indicates a line in first file
  • a, c, or d indicates an ed command, a append, c
    change, d mean delete.
  • 0 third char indicates a line in second file.
  • lt pointing first file
  • gt pointing second file
  • unixgt diff f.txt g.txt
  • 1d0
  • lt jay
  • 2a2
  • gt kit

Page 67
10
Regular Expression rules
  • . Matches any single character For example .at
    matches aat, bat, cat,
  • matches one character between brackets
  • "-" indicates range. E.g. a-z
  • matches zero or more instance, For example ba
    macthes b, ba, baa,
  • \ treat the next character literally, for example
    \ matches "
  • matches the start of the line, So cat matches
    every line that start with cat
  • matches the end of line. So cat matches every
    line that end with cat e.g. aristocat

Page 69, 70
11
grep (global regular expression print)
  • unixgtcat f.txt
  • jay
  • pat
  • sam
  • joe
  • unixgtcat g.txt
  • pat
  • kit
  • sam
  • joe
  • unixgt grep pat f.txt g.txt
  • f.txtpat
  • g.txtpat
  • unixgt grep n pat f.txt g.txt
  • f.txt2pat
  • g.txt1pat

Page 70
12
grep (global regular expression print)
  • unixgtcat f.txt
  • jay
  • pat
  • sam
  • joe
  • unixgtcat g.txt
  • pat
  • kit
  • sam
  • joe
  • Search all rows start with "p"
  • unixgt grep n 'p' f.txt
  • 2pat
  • Search all rows start with "k or j"
  • unixgt grep n 'kj' g.txt
  • g.txt2kit
  • g.txt4joe
  • Search all rows with one or more "a"
  • unixgt grep n 'a' g.txt
  • g.txt1pat
  • g.txt3sam

Page 70
13
egrep (extended global regular expression print)
  • Some of the extended set is as follow
  • matches one or more of its preceding
    characters, e.g. abc2 will match abc2, abc22,
    abc222,
  • ? matches zero or one character that precedes it,
    e.g. abc? Matches with ab and abc
  • signifies an alternative or disjunction. e.g.
    ab means a or b
  • unixgt egrep uuww /usr/dict/words
  • Continuum
  • Hollowware
  • vacuum

Page 72
14
egrep (extended global regular expression print)
  • Search for line that have z or v in info.txt
  • unixgt egrep '(zv)' info.txt
  • Name David I. Schwartz
  • Favorite Color blue

Page 72
15
Printing Files
  • The common print command is lp, which stands for
    line printer, lp work with spooling a file.
  • unixgt lp info.txt
  • request if is jaded-2 (1 file)
  • Request id has the form printer-job number .
  • jaded is a printer.
  • My job is the 2nd print job.
  • unixgt echo PRINTER
  • jaded

Page 72
16
Find other printers
  • unixgt printers
  • Printer Type Location Owner/User
  • astro HP2420 ROOM 271

17
Print to Destination
  • unixgt lp d astro a.txt
  • Some version of unix use the BSD print command
  • unixgt lpr P astro b.txt

Page 73
18
Printing Status
  • lpq and lpstat have different output format
  • unixgt lpstat
  • Jaded-2 dis 163 Nov 22 1833
  • unixgt lpq
  • Jaded_at_blather 0 jobs

Page 73
19
Cancel a Print Job
  • lpq and lpstat have different output format
  • unixgt lpstat
  • Jaded-2 dis 163 Nov 22 1833
  • unixgt cancel jaded-2
  • request "jaded-2" cancelled

Page 74
20
PostScript
  • PostScript (PS) is a text-based language that can
    describe graphical images and text.
  • You should be able to print a PS document
    anywhere.
  • PS document can be generated from a text file
    with genscript.
  • unixgt genscript info.txt gt info.ps
  • unixgt

Page 74
21
View PostScript Document
  • Use ghostview or gs to view PS version of info.ps
  • unixgt gs info.ps
  • GSgt quit
  • unixgt

Page 75
22
Print PostScript Document
  • unixgt lp d jaded info.ps
  • unixgt
  • You can do some conversions at the Unix command
    line.
  • pdf2ps convert PDF file to PS format
  • ps2pdf convert PS file to PDF format
  • ps2ascii convert PS file to ACSII format
  • PDF (portable Document Format) need acroread or
    xpdf utilities to display the PDF file

Page 75
23
Viewing and Printing PDF Files
  • unixgt acroread info.pdf
  • unixgt
  • You can do some conversions at the Unix command
    line.
  • pdf2ps convert PDF file to PS format
  • ps2pdf convert PS file to PDF format
  • ps2ascii convert PS file to ACSII format
  • PDF (portable Document Format) need acroread or
    xpdf utilities to display the PDF file

Page 75
24
Encrypting a File
  • unixgt cat info.txt
  • Trans fat is evil.
  • unixgt crypt lt info.txt gt info.enc
  • Enter Key (Enter 12345)
  • Try more info.enc, unix wil prompt you to view a
    binary file.

25
Decrypting a File
  • unixgt crypt lt info.enc gt info.dec
  • Enter Key (Enter 12345)
  • Try more info.dec, unix wil prompt you to view a
    binary file.
  • unixgt more info.dec
  • Trans fat is evil.

26
mpage versus enscript
  • mpage to print multiple page on one sheet, you
    can print 1, 2, 4 or 8 pages on one side of a
    sheet of paper.
  • If mpage is not available then use enscript

27
Print a File using enscript
  • unixgt enscript r B columns4 f Helvetica10 p
    movies.ps movies.txt
  • This command will create movies.ps from
    movies.txt
  • The enscript command do the following
  • print PS file (-p info.txt)
  • in landscape (-r)
  • with no header (-B)
  • four column (--columns4)
  • in a plain font (-f Helvetica10)
Write a Comment
User Comments (0)
About PowerShow.com