Professional Documents
Culture Documents
Unix - Ii
Unix - 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
© 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
© 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
© 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)
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
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.
© 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.