UNIX COMMANDS
I File and Directory Related commands
1) pwd
This command prints the current working directory
[it23it060@localhost it23it060]$ pwd
/home/it23it060
2) ls
This command displays the list of files in the current working
directory. $ls –l Lists the files in the long format
$ls –t Lists in the order of last modification time
$ls -u Lists in order of last access time
[it23it060@localhost it23it060]$ ls
CS8461 /OPERATING SYSTEMS LAB//2018-19 EVEN SEM/Dept of IT. P a g e | 1
aa arithmetic big big2 dd intrest saok swcs
ari bb big1 cc fgu sample ss
[it23it060@localhost it23it060]$ ls -l
total 56
-rw-rw-r-- 2 it23it060 it23it060 9 Dec 17 11:04 aa
-rw-rw-r-- 1 it23it060 it23it060 147 Dec 17 10:57 ari
-rw-rw-r-- 1 it23it060 it23it060 150 Dec 9 15:32 arithmeti
---------- 1 it23it060 it23it060 13 Dec 17 10:58 bb
-rw-rw-r-- 1 it23it060 it23it060 0 Dec 17 11:11 big
---x--x--x 1 it23it060 it23it060 151 Dec 17 11:11 big1
-rwxrwxrwx 1 it23it060 it23it060 151 Dec 17 12:20 big2
-rw-rw-r-- 1 it23it060 it23it060 22 Dec 17 10:59 cc
-rw-rw-r-- 2 it23it060 it23it060 9 Dec 17 11:04 dd
-rw-rw-r-- 1 it23it060 it23it060 7 Dec 9 15:17 fgu
-rw-rw-r-- 1 it23it060 it23it060 80 Dec 9 15:38 intrest
-rw-rw-r-- 1 it23it060 it23it060 3 Dec 9 15:02 sample
-rw-rw-r-- 1 it23it060 it23it060 7 Dec 9 15:10 saok
drwxrwxr-x 2 it23it060 it23it060 4096 Dec 17 11:14 ss
-rw-rw-r-- 1 it23it060 it23it060 240 Dec 9 14:20 swcs
[it23it060@localhost it23it060]$ ls -t
big2 big1 aa cc ari arithmetic saok swcs
ss big dd bb intrest fgu sample
[it23it060@localhost it23it060]$ ls -u
ss big1 aa cc ari arithmetic saok swcs
big2 big dd bb intrest fgu sample
3) cd
This command is used to change from the working directory to any other directory
specified. $cd directoryname
[it23it060@localhost it23it060]$ cd ss
[it23it060@localhost ss]$ pwd
/home/it23it060/ss
4) cd ..
This command is used to come out of the current working directory.
$cd ..
[it23it060@localhost ss]$ cd ..
[it23it060@localhost it23it060]$
5) mkdir
This command helps us to make a directory.
$mkdir directoryname
[it23it060@localhost it23it060]$ mkdir os
[it23it060@localhost it23it060]$ ls
aa arithmetic big big2 dd intrest sample ss
ari bb big1 cc fgu os saok swcs
CS8461 /OPERATING SYSTEMS LAB//2018-19 EVEN SEM/Dept of IT. P a g e | 2
6) rmdir
This command is used to remove a directory specified in the command line. It requires
the specified directory to be empty before removing it.
$rmdir directoryname
[it23it060@localhost it23it060]$ rmdir os
[it23it060@localhost it23it060]$ ls
aa arithmetic big big2 dd intrest saok swcs
ari bb big1 cc fgu sample ss
7) cat
cat filename – This is used to list the contents of file we specify.
cat > filename – This is used to create a new file. To end typing press
Ctrl+d. cat >>filename – This is used to append the contents of the
file
[it23it060@localhost it23it060]$ cat > aaa
hi how r u
[it23it060@localhost it23it060]$ cat aaa
hi how r u
[it23it060@localhost it23it060]$ cat >> aaa
i am fine
[it23it060@localhost it23it060]$ cat aaa
hi how r u
i am fine
8) cp
This command helps us to create duplicate copies of ordinary files.
$cp source destination
[it23it060@localhost it23it060]$ cat dd
fifndfjd
[it23it060@localhost it23it060]$ cp aaa dd
[it23it060@localhost it23it060]$ cat dd
hi how r u
i am fine
[it23it060@localhost it23it060]$ cp aaa bbb
[it23it060@localhost it23it060]$ cat bbb
hi how r u
i am fine
9) mv
This command is used to move files.
$mv source destination
[it23it060@localhost it23it060]$ ls
aa ari bb big big2 dd intrest saok swcs
aaa arithmetic bbb big1 cc fgu sample ss
[it23it060@localhost it23it060]$ mv aaa aaa1
[it23it060@localhost it23it060]$ ls
aa ari bb big big2 dd intrest saok swcs
aaa1 arithmetic bbb big1 cc fgu sample ss
CS8461 /OPERATING SYSTEMS LAB//2018-19 EVEN SEM/Dept of IT. P a g e | 3
10) rm
This command is used to delete one or more files from the directory.
$rm [option] filename
$rm –i Asks the user if he wants to delete the file mentioned.
$rm –r Recursively delete the entire contents of the directory as well as the directory
itself.
[it23it060@localhost it23it060]$ rm aa
[it23it060@localhost it23it060]$ ls
aaa1 arithmetic bbb big1 cc fgu sample ss
ari bb big big2 dd intrest saok swcs
[it23it060@localhost it23it060]$ rm -i cc
rm: remove regular file `cc'? y
[it23it060@localhost it23it060]$ ls
aaa1 arithmetic bbb big1 dd intrest saok swcs
ari bb big big2 fgu sample ss
[it23it060@localhost it23it060]$ rm -r ss
[it23it060@localhost it23it060]$ ls
aaa1 arithmetic bbb big1 dd intrest saok
ari bb big big2 fgu sample swcs
11) chmod
Changes the file/directory permission mode: $ chmod 777 file1
Gives full permission to owner, group and others
[it23it060@localhost it23it060]$ ls -l
total 52
-rw-rw-r-- 1 it23it060 it23it060 21 Jan 3 12:47 aaa1
-rw-rw-r-- 1 it23it060 it23it060 147 Dec 17 10:57 ari
-rw-rw-r-- 1 it23it060 it23it060 150 Dec 9 15:32 arithmeti
---------- 1 it23it060 it23it060 13 Dec 17 10:58 bb
-rw-rw-r-- 1 it23it060 it23it060 21 Jan 3 12:54 bbb
-rw-rw-r-- 1 it23it060 it23it060 0 Dec 17 11:11 big
---x--x--x 1 it23it060 it23it060 151 Dec 17 11:11 big1
-rwxrwxrwx 1 it23it060 it23it060 151 Dec 17 12:20 big2
-rw-rw-r-- 1 it23it060 it23it060 21 Jan 3 12:53 dd
-rw-rw-r-- 1 it23it060 it23it060 7 Dec 9 15:17 fgu
-rw-rw-r-- 1 it23it060 it23it060 80 Dec 9 15:38 intrest
-rw-rw-r-- 1 it23it060 it23it060 3 Dec 9 15:02 sample
-rw-rw-r-- 1 it23it060 it23it060 7 Dec 9 15:10 saok
-rw-rw-r-- 1 it23it060 it23it060 240 Dec 9 14:20 swcs
[it23it060@localhost it23it060]$ chmod 777 aaa1
[it23it060@localhost it23it060]$ ls -l
total 52
-rwxrwxrwx 1 it23it060 it23it060 21 Jan 3 12:47 aaa1
-rw-rw-r-- 1 it23it060 it23it060 147 Dec 17 10:57 ari
-rw-rw-r-- 1 it23it060 it23it060 150 Dec 9 15:32 arithmeti
---------- 1 it23it060 it23it060 13 Dec 17 10:58 bb
-rw-rw-r-- 1 it23it060 it23it060 21 Jan 3 12:54 bbb
-rw-rw-r-- 1 it23it060 it23it060 0 Dec 17 11:11 big
CS8461 /OPERATING SYSTEMS LAB//2018-19 EVEN SEM/Dept of IT. P a g e | 4
---x--x--x 1 it23it060 it23it060 151 Dec 17 11:11 big1
-rwxrwxrwx 1 it23it060 it23it060 151 Dec 17 12:20 big2
-rw-rw-r-- 1 it23it060 it23it060 21 Jan 3 12:53 dd
-rw-rw-r-- 1 it23it060 it23it060 7 Dec 9 15:17 fgu
-rw-rw-r-- 1 it23it060 it23it060 80 Dec 9 15:38 intrest
-rw-rw-r-- 1 it23it060 it23it060 3 Dec 9 15:02 sample
-rw-rw-r-- 1 it23it060 it23it060 7 Dec 9 15:10 saok
-rw-rw-r-- 1 it23it060 it23it060 240 Dec 9 14:20 swcs
$ chmod o-w file1
Removes write permission for others.
[it23it060@localhost it23it060]$ chmod o-w big2
[it23it060@localhost it23it060]$ ls -l
total 52
-rwxrwxrwx 1 it23it060 it23it060 21 Jan 3 12:47 aaa1
-rw-rw-r-- 1 it23it060 it23it060 147 Dec 17 10:57 ari
-rw-rw-r-- 1 it23it060 it23it060 150 Dec 9 15:32 arithmetic
---------- 1 it23it060 it23it060 13 Dec 17 10:58 bb
-rw-rw-r-- 1 it23it060 it23it060 21 Jan 3 12:54 bbb
-rw-rw-r-- 1 it23it060 it23it060 0 Dec 17 11:11 big
---x--x--x 1 it23it060 it23it060 151 Dec 17 11:11 big1
-rwxrwxr-x 1 it23it060 it23it060 151 Dec 17 12:20 big2
-rw-rw-r-- 1 it23it060 it23it060 21 Jan 3 12:53 dd
-rw-rw-r-- 1 it23it060 it23it060 7 Dec 9 15:17 fgu
-rw-rw-r-- 1 it23it060 it23it060 80 Dec 9 15:38 intrest
-rw-rw-r-- 1 it23it060 it23it060 3 Dec 9 15:02 sample
-rw-rw-r-- 1 it23it060 it23it060 7 Dec 9 15:10 saok
-rw-rw-r-- 1 it23it060 it23it060 240 Dec 9 14:20 swcs
II) Process and status information commands
1) who
This command gives the details of who all have logged in to the UNIX system
currently. $ who
[it23it060@localhost it23it060]$ who
root :0 Jan 3 07:34
it23it06 pts/2 Jan 3 12:32 (192.168.6.86)
it23it02 pts/4 Jan 3 12:33 (192.168.6.73)
it23it02 pts/5 Jan 3 12:38 (192.168.6.78)
it23it02 pts/7 Jan 3 12:45 (192.168.6.65)
it23it08 pts/3 Jan 3 12:45 (192.168.6.68)
it23it03 pts/6 Jan 3 12:53 (192.168.6.62)
it23it03 pts/8 Jan 3 12:53 (192.168.6.67)
it23it03 pts/9 Jan 3 12:54 (192.168.6.76)
it23it02 pts/1 Jan 3 12:59 (192.168.6.70)
CS8461 /OPERATING SYSTEMS LAB//2018-19 EVEN SEM/Dept of IT. P a g e | 5
2) who am i
This command tells us as to when we had logged in and the system’s name for the
connection being used.
$who am i
[it23it060@localhost it23it060]$ who am i
it23it06 pts/2 Jan 3 12:32 (192.168.6.86)
3) date
This command displays the current date in different formats.
+%D mm/dd/yy +%w Day of the week
+%H Hr-00 to 23 +%a Abbr.Weekday
+%M Min-00 to 59 +%h Abbr.Month
+%S Sec-00 to 59 +%r Time in AM/PM
+%T HH:MM:SS +%y Last two digits of the year
4) calender
cal – Calender of the current month.
[it23it060@localhost it23it060]$ cal
January 2015
Su Mo Tu We Th Fr Sa
123
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
cal year – Displays calender for all months of the specified year.
cal month year - Displays calender for the specified month of the year
5) echo
This command will display the text typed from the keyboard.
$echo
Eg: $echo Have a nice day
O/p Have a nice day
III Text related commands
1. head
This command displays the initial part of the file. By default it displays first ten lines of
the file.
$head [filename] – Displays first 10 lines(records) by default.
$head [-count] [filename] – Displays first count number of
lines(records) $head -1 [filename] | wc –c – Length of a line
[it23it060@localhost it23it060]$ cat > records
1|aaa|it
5|bbb|cse
CS8461 /OPERATING SYSTEMS LAB//2018-19 EVEN SEM/Dept of IT. P a g e | 6
2|ddd|eee
4|ccc|it
3|eee|cse
7|ggg|cse
9|abc|eee
6|bcd|it
10|cfd|eee
11|grs|it
8|kas|cse
[it23it060@localhost it23it060]$ cat records
1|aaa|it
5|bbb|cse
2|ddd|eee
4|ccc|it
3|eee|cse
7|ggg|cse
9|abc|eee
6|bcd|it
10|cfd|eee
11|grs|it
8|kas|cse
[it23it060@localhost it23it060]$ head records
1|aaa|it
5|bbb|cse
2|ddd|eee
4|ccc|it
3|eee|cse
7|ggg|cse
9|abc|eee
6|bcd|it
10|cfd|eee
11|grs|it
[it23it060@localhost it23it060]$ head -5 records
1|aaa|it
5|bbb|cse
2|ddd|eee
4|ccc|it
3|eee|cse
[it23it060@localhost it23it060]$ head -1 records | wc -c9
2. tail
This command displays the later part of the file. By default it displays last ten lines of
the file.
$tail [filename] – Displays last 10 lines(records) by default.
$tail [-count] [filename] - Displays last count number of lines(records) $tail[-count]
[filename] | tee newfile - last count number of lines(records) listed and stored in file
newfile using tee
[it23it060@localhost it23it060]$ tail records
CS8461 /OPERATING SYSTEMS LAB//2018-19 EVEN SEM/Dept of IT. P a g e | 7
5|bbb|cse
2|ddd|eee
4|ccc|it
3|eee|cse
7|ggg|cse
9|abc|eee
6|bcd|it
10|cfd|eee
11|grs|it
8|kas|cse
[it23it060@localhost it23it060]$ tail -5 records
9|abc|eee
6|bcd|it
10|cfd|eee
11|grs|it
8|kas|cse
[it23it060@localhost it23it060]$ tail -5 records | tee last5
9|abc|eee
6|bcd|it
10|cfd|eee
11|grs|it
8|kas|cse
[it23it060@localhost it23it060]$ cat last5
9|abc|eee
6|bcd|it
10|cfd|eee
11|grs|it
8|kas|cse
IV Useful Commands:
1) exit - Ends your work on the UNIX system.
2) Ctrl-l or clear
Clears the screen.
3) Ctrl-c
Stopsthe program currently running.
4) Ctrl-z
Pauses the currently running program.
5) man COMMAND
Looks up the UNIX command COMMAND in the online manual
pages. 6) history
List all commands typed so far.
7) more FILE
Display the contents of FILE, pausing after each screenful.
There are several keys which control the output once a screenful has been
printed. <enter> Will advance the output one line at a time.
<space bar> Will advance the output by another full screenful. "q" Will quit and return
you to the UNIX prompt.
8) less FILE
CS8461 /OPERATING SYSTEMS LAB//2018-19 EVEN SEM/Dept of IT. P a g e | 8
"less" is a program similar to "more", but which allows backward movement in the
file as well as forward movement.
9) lpr FILE
To print a UNIX text or PostScript file, type the following command at the system
prompt:Meta characters
Some special characters, called metacharacters may be used to specify multiple
filenames. These characters substitute filenames or parts of filenames.
The “*” This character is used to indicate any character(s)
$ cat ap* This displays the contents of all files having a name starting with ap
followed by any number of characters.
The “?” This character replaces any one character in the
filename. $ ls ?st
list all files starting with any character followed by st.
The [] These are used to specify range of characters.
$ ls [a-z]pple
Lists all files having names starting with any character from a to z.
Absolute path and relative path
Generally if a command is given it will affect only the current working directory.
For example the following command will create a directory named curr in the
current working directory.
$ mkdir curr
The directory can also be created else where in the file system using the absolute and
relative path.If the path is given with respect to the root directory then it is called full
path or absolute path $ mkdir /home/it2006/it2k601/curr
The full path always start with the /, which represents the root directory. If the path is
given with respect to the current working directory or parent directory then it is called
relative path.
$ mkdir ../curr
The above command will create a directory named curr in the parent
directory. $ mkdir ./first/curr
The above command will create a directory named curr inside first directory , where
the
directory first is located in the current working directory.
Note “.” Represents current directory and “..” represents parent
directory. [it23it060@localhost it23it060]$ ls
aaa1 arithmetic bbb big1 dd intrest records saok
ari bb big big2 fgu last5 sample swcs
[it23it060@localhost it23it060]$ mkdir /home/it23it060/ss
[it23it060@localhost it23it060]$ ls
aaa1 arithmetic bbb big1 dd intrest records saok swcs
ari bb big big2 fgu last5 sample ss
[it23it060@localhost it23it060]$ mkdir ./sss
[it23it060@localhost it23it060]$ ls
aaa1 arithmetic bbb big1 dd intrest records saok sss
ari bb big big2 fgu last5 sample ss swcs
[it23it060@localhost it23it060]$ cd sss
[it23it060@localhost sss]$ mkdir ../sss1
CS8461 /OPERATING SYSTEMS LAB//2018-19 EVEN SEM/Dept of IT. P a g e | 9
[it23it060@localhost sss]$ ls
[it23it060@localhost sss]$ cd ..
[it23it060@localhost it23it060]$ ls
aaa1 arithmetic bbb big1 dd intrest records saok sss swcs
ari bb big big2 fgu last5 sample ss sss1
V FILTERS
Filters are used to extract the lines, which contain a specific pattern, to arrange the
contents of a file in a sorted order, to replace existing characters with some other
characters, etc. 1.Sort filter
It is used to reorder file as per ASCII sequence. The t option is used to specify the
delimiter Sort filename – Sorted on 1 column by default
st
Sort –t \| +count filename – Sort as per (count+1)th column.
Sort –t \| -nr +count filename – Sort on numeric field as per (count+1)th column
and r for reverse.
[it23it060@localhost it23it060]$ cat > rec
210|aaa|it |3000
201|bbb|cse|2900
204|abb|eee|2903
203|ccc|ece|2678
202|ddd|it |4000
208|dce|cse|3675
[it23it060@localhost it23it060]$
[it23it060@localhost it23it060]$ cat rec
210|aaa|it |3000
201|bbb|cse|2900
204|abb|eee|2903
203|ccc|ece|2678
202|ddd|it |4000
208|dce|cse|3675
[it23it060@localhost it23it060]$ sort rec
201|bbb|cse|2900
202|ddd|it |4000
203|ccc|ece|2678
204|abb|eee|2903
208|dce|cse|3675
210|aaa|it |3000
[it23it060@localhost it23it060]$ sort -t \| +1 rec
210|aaa|it |3000
204|abb|eee|2903
201|bbb|cse|2900
203|ccc|ece|2678
208|dce|cse|3675
202|ddd|it |4000
[it23it060@localhost it23it060]$ sort -t \| -nr +3 rec
202|ddd|it |4000
208|dce|cse|3675
CS8461 /OPERATING SYSTEMS LAB//2018-19 EVEN SEM/Dept of IT. P a g e | 10
210|aaa|it |3000
204|abb|eee|2903
201|bbb|cse|2900
203|ccc|ece|2678
2.Cut command
One particular field from any file or from output of any command can be extracted
and displayed using this cut command. The d option specifies the delimiter and f for
specifying the field list.
Cut –d \| -f 1,3 filename – Fields 1,3 listed
Cut –d \| -f 2-4 filename – Fields 2,3,4 listed
Paste –d \| file1 file2 – merges two cut files file1 and file2
[it23it060@localhost it23it060]$ cat rec
210|aaa|it |3000
201|bbb|cse|2900
204|abb|eee|2903
203|ccc|ece|2678
202|ddd|it |4000
208|dce|cse|3675
[it23it060@localhost it23it060]$ cut -d \| -f 1,3 rec
210|it
201|cse
204|eee
203|ece
202|it
208|cse
[it23it060@localhost it23it060]$ cut -d \| -f 2-4 rec
aaa|it |3000
bbb|cse|2900
abb|eee|2903
ccc|ece|2678
ddd|it |4000
dce|cse|3675
[it23it060@localhost it23it060]$ cut -d \| -f 1 rec >r1
[it23it060@localhost it23it060]$ cut -d \| -f 3 rec >r2
[it23it060@localhost it23it060]$ paste -d \| r1 r2
210|it
201|cse
204|eee
203|ece
202|it
208|cse
3. nl command
It displays the file content with lines numbered. The s option is used to specify the
seperator.
nl –s “|” filename – Displays entries numbered with seperator |
CS8461 /OPERATING SYSTEMS LAB//2018-19 EVEN SEM/Dept of IT. P a g e | 11
[it23it060@localhost it23it060]$ nl -s "|" rec
1|210|aaa|it |3000
2|201|bbb|cse|2900
3|204|abb|eee|2903
4|203|ccc|ece|2678
5|202|ddd|it |4000
6|208|dce|cse|3675
4. tr command
This command is used to translate characters.It is used to change text case. It
works with standard input <.
Tr ‘[a-z]’ ‘[A-Z]’ < filename
[it23it060@localhost it23it060]$ tr '[a-z]' '[A-Z]' <rec
210|AAA|IT |3000
201|BBB|CSE|2900
204|ABB|EEE|2903
203|CCC|ECE|2678
202|DDD|IT |4000
208|DCE|CSE|3675
5.Grep filter
This command is used to search for a particular pattern from a file or from standard
input and display those lines on the standard output. Grep stands for “Global search for
regular expression”.
There are various options available with grep command.
Grep str filename – Lists the lines that contains the string str.
Grep ‘str1 str2’ filename – Quotes for text containing space.
Grep –c str filename – Number of occurrence of word str in filename.
Grep –n str filename – Displays line along with matching string str.
Grep –v str filename – Displays lines that does not contain text str.
Grep ‘^[0-9]’ filename – Displays lines that start bwith a number.
Grep ‘[0-9]$’ filename – Displays lines that end with a number.
Grep –c “^$” filename – Displays the count of blank lines in the file.
Egrep “lower|UPPER” filename – Displays lines that match either lower or
upper. Egrep “(str1|str2) str3” filename – Displays lines that match either str1
str3 or str2 str3. [it23it060@localhost it23it060]$ cat > demo1
THIS LINE IS THE UPPER CASE LINE IN THIS FILE.
this line is the lower case line in this file.
This Line Has All Its First Character Of The Word With Upper Case.
Two lines above this empty.
1. e - go to the end of current word.
2. E - go to the end of current WORD.
3. b - go to the previous word.
4. B - go to the previous WORD.
WORD - WORD consists of a sequence of non-blank characters.
CS8461 /OPERATING SYSTEMS LAB//2018-19 EVEN SEM/Dept of IT. P a g e | 12
Word - word consists of a sequence of letters, digits and underscores.
telnet 192.168.6.201
[it23it060@localhost it23it060]$ cat demo1
THIS LINE IS THE UPPER CASE LINE IN THIS
FILE. this line is the lower case line in this file.
This Line Has All Its First Character Of The Word With Upper
Case. Two lines above this empty.
1. e - go to the end of current word.
2. E - go to the end of current WORD.
3. b - go to the previous word.
4. B - go to the previous WORD.
WORD - WORD consists of a sequence of non-blank
characters. Word - word consists of a sequence of letters, digits
and underscores.
telnet 192.168.6.201
[it23it060@localhost it23it060]$ grep this demo1
this line is the lower case line in this file.
Two lines above this empty.
[it23it060@localhost it23it060]$ grep 'end of' demo1
1. e - go to the end of current word.
2. E - go to the end of current WORD.
[it23it060@localhost it23it060]$ grep -c to demo1
4
[it23it060@localhost it23it060]$ grep -n sequence demo1
12:WORD - WORD consists of a sequence of non-blank
characters. 13:Word - word consists of a sequence of letters,
digits and underscores [it23it060@localhost it23it060]$ grep -v
word demo1
THIS LINE IS THE UPPER CASE LINE IN THIS
FILE. this line is the lower case line in this file.
This Line Has All Its First Character Of The Word With Upper
Case. Two lines above this empty.
2. E - go to the end of current WORD.
4. B - go to the previous WORD.
WORD - WORD consists of a sequence of non-blank characters.
telnet 192.168.6.201
[it23it060@localhost it23it060]$ grep '^[0-9]' demo1
1. e - go to the end of current word.
2. E - go to the end of current WORD.
3. b - go to the previous word.
4. B - go to the previous WORD.
CS8461 /OPERATING SYSTEMS LAB//2018-19 EVEN SEM/Dept of IT. P a g e | 13
[it23it060@localhost it23it060]$ grep '[0-9]$' demo1
telnet 192.168.6.201
[it23it060@localhost it23it060]$ grep -c "^$" demo1
4
[it23it060@localhost it23it060]$ egrep "lower|UPPER" demo1
THIS LINE IS THE UPPER CASE LINE IN THIS FILE.
this line is the lower case line in this file.
[it23it060@localhost it23it060]$ egrep "(previous|current)word"
demo1 [it23it060@localhost it23it060]$ egrep "(previous|current)
word" demo1 1. e - go to the end of current word.
3. b - go to the previous word.