Your Only Destination To Empower Your Computer Programing Knowledge. Sky is not so high, You can Touch it if You Try

Script for making use of multiple options of sed command.

echo Enter the given database
read a1
echo
echo Database is
cat $a1
echo
echo Show first three lines of database:
sed '3q' $a1
echo
echo show database within a range 2-4:-
sed -n '2,4p' $a1
echo
echo Show database within range 3-7 and last line
sed -n -e '3,7p' -e '$p' $a1
echo
echo Show lines having pattern Meenu
sed -n '/[Mn]eenu/p' $a1



Output:-

Enter the given database
Database

Database is
|Name |Age |salary |contact no.
|Meenu |23 |40000 |7206297384
|jyoti |20 |35000 |9813456782
|mamta |21 |32000 |9017720166
|kavita |22 |30000 |9014445623
|neha |23 |34500 |8014465777
|sanchi |24 |23000 |9014356278
|nishtha |25 |24567 |7289786254
|mohina |19 |45000 |9824568753
|mohit |22 |43000 |7013442455
|pooja |21 |34590 |9013324658
|monika |34 |23000 |7823445678
|neenu |33 |34000 |8076543210

Show first three lines of database:
|Name |Age |salary |contact no.
|Meenu |23 |40000 |7206297384
|jyoti |20 |35000 |9813456782
show database within a range 2-4:-
|Meenu |23 |40000 |7206297384
|jyoti |20 |35000 |9813456782
|mamta |21 |32000 |9017720166

Show database within range 3-7 and last line
|jyoti |20 |35000 |9813456782
|mamta |21 |32000 |9017720166
|kavita |22 |30000 |9014445623
|neha |23 |34500 |8014465777
|sanchi |24 |23000 |9014356278
|neenu |33 |34000 |8076543210

|Show lines having pattern Meenu
|Meenu |23 |40000 |7206297384
|neenu |33 |34000 |8076543210

No comments:

Post a Comment