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

Script to sort the contents of file

echo Enter name of file
read a
echo
echo Contents of file are:-
cat $a
echo
echo After sorting, contents are:-
sort $a
echo
echo Enter two files for sorting
read a
read b
echo
echo After sorting of these files, contents are:-
sort $a $b
echo
echo Store sorted output in a new file name kannu
sort -okannu $a $b
echo
echo Showing contents of file kannu
cat kannu
~
~
~
~
~
~



Output:-

Enter name of file
Records

Contents of file are:-
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
meena |24 |32000 |9876543210
sonika |20 |43000 |8097634521
meenal |34 |31000 |8709653412

After sorting,contents are:-
jyoti |20 |35000 |9813456782
kavita |22 |30000 |9014445623
mamta |21 |32000 |9017720166
meena |24 |32000 |9876543210
meenal |34 |31000 |8709653412
Meenu |23 |40000 |7206297384
mohina |19 |45000 |9824568753
mohit |22 |43000 |7013442455
monika |34 |23000 |7823445678
neenu |33 |34000 |8076543210
neha |23 |34500 |8014465777
nishtha |25 |24567 |7289786254
pooja |21 |34590 |9013324658
sanchi |24 |23000 |9014356278
sonika |20 |43000 |8097634521

Enter two files for sorting
rain
menu

After sorting of these files,contens are:-
book
come to lab
cook
dook
kook
kool
look

Store sorted output in a new file name kannu

Showing contents of file kannu
book
come to lab
cook
dook
kook
kool
look

No comments:

Post a Comment