Академический Документы
Профессиональный Документы
Культура Документы
03 Advanced filters such as egrep, fgrep, tr, sed, awk. 13-20 06/01/2016
04 File operation commands such as split, tar, find, zip, In, 21-23 13/01/2017
chmod.
05 Basic shell scripting such as defining variables, reading user 24-28 20/01/2017
input, condition, loops, string operations, arithmetic
operations.
06 Advanced shell scripting such as environment variables, 29-31 27/01/2017
shell features, commands line arguments, file tests using
backticks.
07 Process management such as ps, jobs, nice, fg, bg, at 32-35 03/02/2017
1
Date: 09/12/2016
Practical 1
Command: - pwd
Syntax: - pwd
This command displays present or current working Directory. It shows the absolute path or full
path of the current directory.
Output: -
$ pwd
/home/tybsc
Command: - cd
Syntax: - cd abc
Changes to the directory name abc. With cd command we can use absolute or relative path to
reach the directory abc. Absolute path is the path which starts from / whereas the relative path is
the path which is relative to the current working directory or starts from the current working
directory. For example:
Command: - mkdir
Syntax: - mkdir DIRECTORY
$ mkdir Images
Creates directory Images in the current directory.
Command: - rmdir
rmdir Images
2
Removes directory Images.
Command: - touch
Syntax: - touch [OPTION].[EXPRESSION].[FILE]
Creates a file if it does not exist. If the file exists then modification and access time are
changed to current or predefined values.
Options: -
-m change modification time.
-a change access time.
Output: -
$ touch emp.lst
File emp.lst is created if it does not exist. If the file emp.lst exists then its modification and
access time is changed to current time. If the modification and access time is to be changed to
some different values then use m and a options.
Command: - cp
Options: -
Command: - rm
3
rm prompts the user for whether to remove the file. If the response does not begin with `y' or
`Y', the file is skipped.
Options: -
For example:
$rm -i tybsc
$rm - r mp3
Command: - mv
Options: -
For example:
Command: - ls
Syntax: - ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Options: -
Redirection:
Logically all files are organized as a continuous stream of bytes in Linux. The user never
references the physical structure of a file. To the user, all files have the same organization -- a
byte stream. Any file can be easily copied or appended to another because all files are organized
in the same way. In this sense, only one standard type exists in Linux, the byte-stream file.
Linux makes no implementational distinction between a character file and a record file, or a text
file and a binary file.
Data input at the keyboard is placed in a data stream arranged as as continuous set of bytes.
Data output from a command or program is also placed in a data stream and arranged as a
continuous set of bytes. This input data stream is referred to as the standard input, while the
output data stream is called the standard output. You can redirect this standard output stream to a
particular file with > symbol.
The output of cat command is redirected from the screen device to a file. The redirection
operation will create the file xyz. If the file is already exists, It will be overwritten with the
data from the standard output.
Many linux commands receive data from the standard input such as file commands or any
device You can take any file contents as standard input .
The contents of file abc are redirected to the cat command which is responsible for
displaying the contents to the screen. We can combine both the redirections as follows:
The cat command receives the input from file abc and the contents is redirected as output to
the file xyz. Hence no contents are displayed to the screen.
$ cat < history . The contents of history command are redirected to cat command. So details
of history file are displayed.
5
$ cat < history > xyz. The contents of history file is redirected as input to cat command which is
again redirected as output from cat command to xyz file.
Pipes: In many situations you may want to send the standard output of one command to another
command, not the destination file. Suppose you want to send the list of files to the printer. For
this you need two commands ie. The ls and lpr command. For this you need to take the output
of ls command and use it as input for the lpr command.
$ ls | lpr You can think of data as flowing from one command to another ( through a pipe) .
To form such a connection in Linux we use what is called as Pipe. We can combine the pipe
operation with other shell features, such as wild cards to perform specialized operations
$ cat abc | lpr Reads and outputs the contents of abc file and then piped to the printer.
$ sort xyz | more The sort command takes the contents of file xyz and generates a version with
each line sorted in alphabetic order. This sorted version is piped through into the more command
for display on the screen. Note that the original file xyz is not been changed or sorted. Only
the output of sort command in the standard output is sorted.
$ sort xyz | cat n | lpr The file xyz will be sorted first which will piped to cat command.The cat
command with n option then takes sorted file as its input and generates the numbered, sorted
list as its output. This numbered, sorted list is then piped to lpr command for printing.
Suppose you want to print a file with the name of its directory at the top
$ pwd | cat xyz | lpr In this case the cat command will have two arguments ie. for the
standard input (from pwd command ) and xyz (name of file). This is then piped to lpr for
printing.
$ pwd | cat xyz | lpr . This will work in the same way but with directory name at the bottom.
Commands such as sort that output a modified version of its input are refered to as filters.
Filters are often used with pipes.
$ cat pqr Suppose file pqr is not present then it will issue an error. The errors can be of all
kinds. Such errors can be stored in some file for further reference. Such as $ cat pqr >
errorfile. To add new error messages to this file we will use >> operator (for appending).
$ cat ls abc >> errorfile In this case errorfile is not overwritten but the new contents are
appended.
6
Date: 13/12/2016
Practical 2
Aim: Basic filter commands such as head, tail, cat, sort, cut, grep.
Command: - head
Print first 10 lines of each FILE to standard output. With more than one FILE, precede each with
a header giving the file name. With no FILE, or when FILE is - read standard input.
Options: -
Output: -
$head 2 sample.txt
Hello I am here
$head -5 abc.txt | sort r (First 5 lines of abc.txt are send to sort command)
Command: - tail
Syntax: - tail [OPTION] [FILE]
Print the last 10 lines of each FILE to standard output. With more than one FILE, precede
each with a header giving the file name. With no FILE, or when FILE is -, read standard input.
Options: -
Output: -
$tail 24c sample.txt
7
Command: - cat
Concatenate FILE(s), or standard input, to standard output. It takes file names for its arguments. It
outputs the content of those files directly to the standard output (by default screen)
Options: -
Output: -
$ cat -n sample.txt
Command: - sort
Syntax: - sort [OPTION]... [FILE]...
Options: -
Output: -
$sort d sample.txt
Because It is the Best.
hello i am hindustani.
$sort r sample.txt
8
-k n sorts on nth field
-k m,n starts sort on mth field and ends sort on nth field
-n sorts numerically
Command: - cut
Options: -
Output: -
$cut c 6-9 emp.lst
ABC
Xyz
9
Command: - paste
Write lines consisting of the sequentially corresponding lines from each FILE, separated by
TABs, to standard output. With no FILE, or when FILE is -, read standard input.
Options: -
Output:-$paste
file1 file2
aaa| QQQ www|iii|III
Grep searches the named input FILEs for lines containing a match to the given PATTERN. By
default, grep prints the matching lines.
Options: -
-i, --ignore-case: Ignore case distinctions in both the PATTERN and the input files.
-l, --files=without-match option.:Suppress normal output; instead print the name of each input
file from which output would normally have been printed. The scanning will stop on the first
match.
-n, --line-number: Prefix each line of output with the line number within its input file.
Examples:-$grep
i hello *
whether:Hello I am a student
$grep l hello *
10
mydata: Hello how are you.
whether:Hello I am a
6 whether:Hello I am a
student $grep v hello *
More Examples
grep is used for searching a string within the file. We can pass a search pattern or regular
expressions to the grep command Regular expression is a expression which consists of elaborate
character set which can be used for searching purpose. Examples : Let us consider a file emp.lst
which contains employee contents as follows:
11
Following commands were executed on the above file:
$ grep Agarwal emp.lst (It will display only single output as follows)
g* --- The * refers to the immediate preceding character. In this case it will match g, gg, ggg,
gggg ( after the original g) etc. It also matches a null string.
Symbols Significance
12
Date: 06/01/2017
Practical 3
Aim: Advanced filters such as egrep, fgrep, tr, sed, awk.
Command: - egrep
egrep searches the named input FILEs for lines containing a match to the given PATTERN. By
default, egrep prints the matching lines.
Options: -
-i, --ignore-case: Ignore case distinctions in both the PATTERN and the input files.
-l, --files=without-match option.:Suppress normal output; instead print the name of each input
file from which output would normally have been printed. The scanning will stop on the first
match.
-n, --line-number: Prefix each line of output with the line number within its input file.
Examples: -
$egrep i hello+ f1.txt f2.txt
f2.txt:Hello I am a student
f6.txt:Hello I am a student
3 gr.tcl:#include<stdio.h>
6 gtk.cpp: #include<conio.h>
13
gt.tcl: how are you now.
gtk.cpp: I am a student of tybsc
fGrep searches the named input FILEs for lines containing a match to the given PATTERN. By
default, grep prints the matching lines.
Options: -
-i, --ignore-case: Ignore case distinctions in both the PATTERN and the input files.
-l, --files=without-match option.:Suppress normal output; instead print the name of each input
file from which output would normally have been printed. The scanning will stop on the first
match.
-n, --line-number: Prefix each line of output with the line number within its input file. -
v, --invert-match: Invert the sense of matching, to select non-matching lines.
Output:-
$fgrep i mydata /home/tybsc
whether:Hello I am a student
whether:Hello I am a student
6 whether:Hello I am a student
$egrep (sen|das)gupta emp.lst (It will display the above same output)
If we want to search more than two patterns then we should pass then as a file
$egrep i agg?[ar]+wal emp.lst ( -i is used for ignoring case while matching. Since this
expression uses some characters not used by the shell at all, it can never expand into a filename.
So in the above example you can safely leave out the quotes).
The above two examples will give appropriate outputs. Please check the outputs)
Expression Significance
15
fgrep : fgrep like egrep accepts multiple patterns, but it doesnt accept regular expression. fgrep
is faster as compared to grep and egrep but is used for searching simple string or group of
strings. fgrep can take patterns from file using f option, but the patterns should be separated by
new line character
admin
accounts
sales )
$grep ^2 emp.lst
$grep 7$ emp.lst
Various options for the grep family is given on page no 174 of Unix : Concepts and
Applications book written by Sumitabha Das)
Command: - tr
Translating Characters.
Options: -
-d deleting characters.
-s squeeing spaces.
16
Examples:-
$tr / ~ <emp.lst (All the / characters in file emp.lst will be replaced by ~ character)
$tr a-z A-Z < emp.lst (All the characters in the file emp.lst will be converted to Upper Case)
$tr A-Z a-z < emp.lst (All the characters in the file emp.lst will be converted to Lower Case)
Sed Editor:
Inserting record:
Sed 1:\
> raj\
> manoj\
> sachin
> f1 > x
3 records (names) along with the contents of the file f1 are inserted into file x. To make
changes permanent to the file f1:
$ mv x f1 : ie Rename file x as f1
17
AWK :
Awk is a programming language which allows easy manipulation of structured data and the
generation of formatted reports. Awk stands for the names of its authors Aho, Weinberger,
and Kernighan
The Awk is mostly used for pattern scanning and processing. It searches one or more files to see if
they contain lines that matches with the specified patterns and then perform associated actions.
Syntax:
Let us create employee.txt file which has the following content, which will be used in the
examples mentioned below.
$cat employee.txt
Example 1.
$ awk '{print;}' employee.txt
100 Thomas Manager Sales $5,000
200 Jason Developer Technology $5,500
300 Sanjay Sysadmin Technology $7,000
400 Nisha Manager Marketing $9,500
500 Randy DBA Technology $6,000
18
In the above example pattern is not given. So the actions are applicable to all the
lines. Action print with out any argument prints the whole line by default. So it prints
all the lines of the file with out fail. Actions has to be enclosed with in the braces.
In the above example it prints all the line which matches with the Thomas or Nisha. It has
two patterns. Awk accepts any number of patterns, but each set (patterns and its
corresponding actions) has to be separated by newline.
Awk has number of built in variables. For each record i.e line, it splits the record delimited by
whitespace character by default and stores it in the $n variables. If the line has 4 words, it will
be stored in $1, $2, $3 and $4. $0 represents whole line. NF is a built in variable which
represents total number of fields in a record.
In the above example, first field ($1) is employee id. So if $1 is greater than 200, then just do the
default print action to print the whole line.
19
Example 6. Print the list of employees in Technology department
Now department name is available as a fourth field, so need to check if $4 matches with
the string Technology, if yes print the line.
Operator ~ is for comparing with the regular expressions. If it matches the default action i.e
print whole line will be performed.
20
Date: 13/01/2017
Practical 4
Aim: File operation commands such as split, tar, find, zip, In, chmod.
Command: - split
Syntax: -split number filename
This command splits the file. By default it splits the file after each 1000 lines, you can specify
the pages setting i.e.72 lines
Output: -
$ split -2 sample.txt
$ ls
xaa (Names of the file which is created after splitting) xab
Tar : The tar utility creates archives for files and directories. Tar stands for Tape archive. It is
similar to ZIP files in windows. The command is as follows $ tar -cf abc.tar mydir ( The
contents of mydir and its sub directories are zipped to abc.tar file)
Creating an archive:
tar -cvf archive.tar *.txt [Where options c stands for create, v for verbose and f for file]
$ tar -xf abc.tar xyz ( the contents of abc.tar are extracted to file xyz)
$ tar -rf abc.tar jkl.c ( r option is used to add files to archive that is already created. The r option
appends the files to the archieve.
$ tar -uf abc.tar mydir ( Updates the abc.tar file with any recently modified or newly created
files in the mydir)
Options: -
21
-name search by name of the file
-inum search by inode number of the file
Output:-
$ find / -name abc.txt
/home/vijay/abc.txt
In the above example the file abc.txt is to be searched from /
directory. $ find . inum 13957
x.txt
In the above example the file with inode number 13957 is to be searched from current
directory. (for current directory dot operator is used)
Command: - zip
Command: - gzip
Command: -bzip2
Command: - ln
Command: - chmod
Description:
Each file and directory in Linux contains a set of permission that determines who can access
them and how. A file and directory may have read, write and execute permission. When a file is
created it is automatically given read and write permission for the owner enabling you to modify
and display the file. A file could also have execute permission allowing it to be executed as a
program. When ls l command is used it displays all the content of the directory in the
following format,
22
The first three characters of first column is for users, second group is for group and the last is
for others. Here r denotes read, w denotes write, x denotes execute.
[r,w,x are character permissions. We can also use octal permissions such as 4 for read, 2 for
write and 1 for execte]
Option: -
+ Adds a permissions
- Removes a permissions
= Assigns entire set of permissions
r Sets read permissions for a file or directory. This type of file can be read and
displayed. A directory can have list of its files displayed.
w Sets write permissions for a file or directory. This type of file can be edited and erased.
A directory can be removed.
x Sets execute permissions for a file or directory. If a file is shell script then it can
be executed as a program. A directory can be changed to and entered.
u Sets permissions for the user who created and owns the file or directory. g
Sets permissions for the group access the file or directory.
o Sets permissions for the other users on the system.
a Sets permissions for access by the user, group and all other users.
$ chmod +x-w mydata: Adding execute permission and removing write permission.
$ chmod 777 mydata: Adding all permission for all type of users(ie owner, group member and
Others)
23
Date: 20/01/2017
Practical 5
Example1:
Conditions:
if test $n gt
0 then
echo $n is positive
else
echo $n is negative
fi
24
#THIS IS PROGRAM FOR IFELSE WITHOUT
TEST echo enter the basic salary
read b
scale = 2
if [$b lt 1500]
then
hra=`echo $b\*10/100|bc l`
da=`echo $b\*90/100|bc l`
else
hra=500
da=`echo $b\*98/100|bc l`
fi
g=`echo $b+$hra+$da|bc l`
echo gross salary = $g
Loops:
while [ $i le 10 ]
do
echo $i
sum=`expr $sum +
$i` i=`expr $i + 1`
done
until [ $i gt 10 ]
do
echo $i
sum=`expr $sum +
$i` i=`expr $i + 1`
done
echo The sum is= $sum
#program: for
loop sum=0
for i in 1 2 3 4 5 6 7 8 9 10
do
sum=`expr $sum +
$i` echo $i
i=`expr $i + 1`
done
echo The sum is= $sum
read num
case $num in
1) echo Sunday;;
2) echo Monday;;
3) echo Tuesday;;
26
4) echo Wednesday;;
5) echo Thursday;;
6) Friday;;
7) Saturday;;
*) echo Enter the number bet 1 to 7;;
String operations:
Comparison Description
str1 = str2 Check if str1 is the same as string
str2. str1 != str2 Check if str1 is not the same as
str2. str1 < str2 Check if str1 is less than str2.
str1 > str2 Check if str1 is greater than str2.
-n str1 Check if str1 has a length greater than
zero. -z str1 Check if str1 has a length of zero.
then
echo THE STRINGS ARE IDENTICAL
else
27
# Program to print even number series.
no=0
echo "Enter
limit" read limit
echo "Even number series"
while [ $no -le $limit ]
do
echo $no
no=`expr $no + 2`
done
28
Date: 27/01/2017
Practical 6
Aim: Advanced shell scripting such as environment variables, shell
features, commands line arguments, file tests using backticks.
if [ $# -ne 1 ]
then
echo Usage : Scriptname Username
exit
fi
29
File tests:
# Check if input filename is a file or directory if it is a directory then list the contents of
directory. If it is a file,check if it has read & write permission.
Program:-
if test -f
$fnm then
if test -w $fnm
then
30
if test -d $fnm
then
echo "$fnm is
directory" pwd
cd $fnm
ls -l
else
echo "$fnm is not directory"
fi
clear
echo Enter filename :
read file
if [ -s $file ]
then
if [ -f $file ]
then
echo "--------------------------------------"
cat $file
echo "--------------------------------------"
elif [ -d $file ]
then
ls -i $file
fi
else
echo "This file is empty"
fi
Backticks:
Practical 7
Aim:- Process management such as ps, jobs, nice, fg, bg, at
ps: ps gives a snapshot of the current processes. If you want a repetitive update of this status,
use top.
Example:
ps -au | less
The -a option tells ps to list the processes of all users on the system rather than just those of
the current user. The -u option tells ps to provide detailed information about each process. less
command is used to view the output one screenful at a time.
You can run a job in the background while you execute other commands.
You can even interrupt a command, starting it again later from where you left off. Background
operations are particularly useful for long jobs. Instead of waiting at the terminal until a
command has finished execution, you can place it in the background. eg. Edit a file while
others files are printing.
You execute a command in the background by placing an ampersand on the command line at
the end of the command
$ lpr abc $
$ jobs
32
Output : [1] + Running lpr abc
When a job in the background completes the system will not notify you about the completed job.
Ie. It will not disturb you. Butif you want to be notified immediately when a certain job ends, no
matter what you are doing on the system you can use notify command
$ fg % 2 . You may not immediately receive the prompt again because the command is now in
the foreground and might be executing.
If you want to stop a job in the background, you can force it to end with the kill command
Process id PID Or
33
You can suspend a job by using ctrl + z keys. This places a job to the side until it is restarted.
The job is not ended but it merely remains suspended until you want to continue. When you
want to continue with the suspended job use fg or bg. The fg command restarts a suspended job
in the foreground. The bg command places the suspended job in the background.
To restart a job in background mode, use the bg command, along with the job number:
$ bg 2 The job is restarted and placed in the background where 2 is job no.
nice:
With the help of Nice command in Linux you can set process priority. If you give a process
a higher priority, then Kernel will allocate more cpu time to that process.
By default when a programe is launched in Linux, it gets launched with the priority of '0'.
However you can change the priority of your programes by either of the following methods.
For example
nice n 10 <command name> Will set a process with the priority of "10".
A process with the nice value of -20 is considered to be on top of the priority. And a process
with nice value of 19 is considered to be low on the priority list.
renice:
In order to change the priority of an already running process you can use "renice" command.
For example
$ renice 10 -p 29504 [this will set the priority of process id no 29504 to 10]
34
at:
By default, the at command submits input from STDIN to the queue. You can specify a
filename used to read commands (your script file) using the -f parameter.
The time parameter specifies when you want the Linux system to run the job. You can get
pretty creative with how you specify the time. The at command recognizes lots of different time
formats:
1. A standard hour and minute, such as 10:15
2. An AM/PM indicator, such as 10:15PM
3. A specific named time, such as now, noon, midnight, or teatime (4PM)
If you specify a time thats already past, the at command runs the job at that time on
the next day.
Besides specifying the time to run the job, you can also include a specific date, using a few
different date formats:
1. A standard date format, such as MMDDYY, MM/DD/YY, or DD.MM.YY
2. A text date, such as Jul 4 or Dec 25, with or without the year
3. You can also specify a time increment:
a) Now + 25 minutes
b) 10:15PM tomorrow
c) 10:15 + 7 days
examples :
$ at -f test5 10:15
warning: commands will be executed using /bin/sh
job 7 at 2007-11-04 10:15
$ at -f test5 4PM
warning: commands will be executed using /bin/sh
job 8 at 2007-11-03 16:00
batch:
You can use the -f parameter to specify a file to read commands from. You can also optionally
specify the earliest time that the batch command should try running the job.
35
Date: 10/02/2017
Practical 8
Logging on to LINUX: You can log into Linux from GUI mode or Command Line mode. You
will be prompted for login name and password. You can work as Administrator or a Normal
user. It is always advised to work as Normal user. Administrator account is used for special
purposes such as doing maintenance work, creating users, changing passwords etc., Use login
name as root and password (which is given during installation) to work as Administrator. The
login name and password is validated, and if found ok, you are allowed to enter and you are
taken directly to your home directory.
Logging out of Linux: To log out use the command exit.
Creating user accounts: To create users use the command useradd or adduser.
Command: - useradd
Syntax: - useradd accountname
Eg. useradd Vijay
Options: - There are many options, which can be used along with useradd command. These
options can be found from man pages.
By default the command creates Vijay directory under /home. This directory is the
home directory for the user Vijay.
Command: - passwd
Syntax: - passwd accountname
Eg. passwd Vijay
For Password Framing Rules and Discipline or Changing password refer to
Unix Concepts and Applications by Sumitabh Das (From Third Edition page no 50 and 51)
Command: - who
Syntax: - who [OPTION]
Options: -
-u displays the information about each connected user such as from where they have logged in
and how long they have been inactive.
36
Output: -
$ who -u
Job control(crontab):
crontab: For commands that need to be executed repeatedly (e.g., hourly, daily, or weekly), you
can use the crontab command. The crontab command creates a crontab file containing commands
and instructions for the cron daemon to execute. You can use the crontab command with the
following options:
crontab -a Install filename as your crontab file. On many systems, this command is
filename executed simply as crontab filename (i.e., without the -a option).
crontab -e Edit your crontab file, or create one if it doesn't already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
Each entry in a crontab file consists of six fields, specifying in the following order:
The fields are separated by spaces or tabs. The first five are integer patterns and the sixth is
the command to execute. The following table briefly describes each of the fields:
$ ls l abc
To change group for the files: To change a group for any file we use the following
command $ chgrp college abc
The chgrp command takes its first argument the name of the new group followed by name of file
( or names of files) for which the group has to changed.
38
Some essential Administrative Commands:
Data Blocks:
All file data are stored in the data blocks, which occupy most of the file system. Block size
in Unix is 512 bytes (1024 in Linux). To find out the disk usage we use commands such as du
and df (check man du and man df)
du:
df:
fdisk:
fdisk is used to create partitions. To check partitions of the hard disk use
$ fdisk /dev/hda
Newly created partitions are useless unless it contain some file system. mkfs command is used
to create file system.
mount command is used to mount file system (can be hard disk, floppy disk etc) as
where t is used to specify the type of file system (here it is ext2) and cdrom is the
mount point (can be any directory)
$ umount /mnt/cdrom
$ umount /abc
39
File System Checking:
Due to any problems the file system becomes inconsistent for eg If power goes off before
the superblock is written to the disk, the file system loses its integrity. There are many events
that can lead to file system corruption, and the most common ones are listed below:
fsck command is used to check and repair the damaged file system. It will phase wise
check all the above problems and try to fix them.
During system start up the most important process, which is started by the system, is the
init process. Its process id is 1. It is responsible for starting of all subsequent processes. Init
can be started with different run levels (init 0, init 1 etc) as follows:
0. System shutdown
1. System administration mode or Single user mode (used for maintainance of the system by
the administrator)
2. Multiuser mode (Networking not available)
3. Multiuser mode (With Networking)
4. Not used currently
5. Full graphical mode (Along with networking)
6. Shutdown and Reboot mode.
So when we execute the command $ init 5 it means that all the services which are required
for graphical and networking interface should be started and so.
40
Date: 17/02/2017
Practical no.9
Write and execute the commands for the following:
i. Display /usr/sbin beginning with a lowercase c.
ii. Display and count all the lines in the file /etc/mime.types
iii. To find out how many files are in the /usr/bin directory.
ii. Display and count all the lines in the file /etc/mime.types
Output:
iii. To find out how many files are in the /usr/bin directory.
Output:
i. Create a file named fsp<seat_no> having the listing of atleast 50 lines (e.g, listing of /usr/sbin
or /usr/bin or /etc or can create your own).
Output:
ii. Display first 2 lines of fsp<seat_no> and convert all the characters into capital letters.
Output:
Output:
42
iv. Display the lines starting with a vowel.
Output:
v. Split the file fsp<seat_no> into subparts each having at most 20 lines and display the
contents of these subparts and count the number of lines in them.
Output:
43
vi. . Split the file fsp<seat_no> into three subparts named fspaa, fspab, fspac and
display the contents of these files and count the number of lines in them.
Output:
Output:
Output: 44
45