UNIX Part - II

Objectives
ls command with options grep command with options gzip and gunzip command Remote Login - telnet FTP Protocol Introduction to Shell Types Shell by examples By:- Kunal Chhajed
© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved.

ls command
–l - to view the permissions –F - tells which are directory –a - displays hidden files also -t - shows you the files in modification time -r - reverses the order of how the files are displayed -1 - print one entry per line of output -c - use time of last modification of the i-node -m - stream output format; files are listed across the page, separated by commas -s - give size in blocks, including indirect blocks, for each entry
© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved.

Regular Expressions
* Zero or more occurrences g* Nothing or g,gg,ggg,etc . A single character .* any number of characters [pqr] A single character p,q or r [1-3] A digit between 1 and 3 [^pqr] A single character which is not a p,q or r [^a-zA-Z] A non alphabetic character ^pat pattern pat beginning of line pat$ pattern pat at the end of line ^pat$ as the only word in line ^$ Lines containing nothing
© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved.

grep
grep Command Syntax:grep [options] pattern filename Options:Ignoring the case :grep –i ‘jain’ emp.lst Inverting(Deleting Lines):grep –v ‘director’ emp.lst > otherlist Displaying Line no.(- n):grep –i ‘marketing’ emp.lst

© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved.

Counting the lines (-c) :grep –c director emp*.lst emp.lst: 4 emp1.lst: 1 emp2.lst: 8 Displaying File names only (- l) :grep –l ‘director’ *.lst Matching Multiple pattern (- e) :grep –e ‘director’ -e ‘manager’ emp.lst

© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved.

gzip, gunzip Compress or expand files
E.g gzip libc.html libc.html.gz -v - display the name and percentage reduction for each file compressed or decompressed. -N - Useful when the time stamp has been lost after a file transfer - f - force compression or decompression if the corresponding file already exists -h – displays the help -q - suppress all warnings

© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved.

Uncompressing a gzipped file gunzip libc.html.gz or gzip –d libc.html (Same .gz assumed) Recursive Compression (-r) Compress all the files found in the subdirectories gzip –r progs (Compress all the files in progs) For Decompression gunzip –r progs or gzip –dr progs

© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved.

Link Command
Use:Calls the link function to create a link to a file. Syntax:link FILE1 FILE2 link OPTION Examples link computer.txt hope.txt Note:The above example would create the file hope.txt in the same directory and be a linked to the computer.txt file. Any changes that occurred with either of these files would affect the other file or link.

© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved.

REMOTE LOGIN
Telnet allows you to log on a remote machine You can use telnet with hostname or IP address As long as you are logged in,anything you type is sent to the remote machine, and your machine acts as dumb terminal. Any files you use or commands that you run will always be on the remote machine. Cntrl + d or type exit to return your local shell

© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved.

File Transfer Protocol - FTP
Options:-

put:- send one file get:- receive one file binary:- set binary transfer prompt:- force interactive prompting on file mput:- send multiple files mget:- get multiple files size:- show size of remote file bye:- terminate ftp session and close modtime:- show last time modification time of remote file
© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved.

END

© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved.