SED - Displaying multiple consecutive lines--------->>sed -n '1p'

 --------------------------------------------------------------------------------------------------
Displaying multiple consecutive lines--------->>sed -n '1p' <filename>
-----------------------------------------------------------------------------------------------
[prabhucloudxlab@cxln4 prabhu]$ cat > filegrep.txt
unix is great os. unix is opensource. unix is free os.
learn operating system.
Unix linux which one you choose.
uNix is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful.
ThIs Is LInux 2000
ThIs Is WIndows 3000
ThIs Is MAC 4000
ThIs Is LInux 2000
ThIs Is WIndows 3000



[prabhucloudxlab@cxln4 ~]$ cat>hello.sh
#! /bin/bash
#Example 4: Reading lines

echo "enter filename to substitute using sed"
read fileName

echo "              "
if [[ -f $fileName ]]
then
echo "#reading 1st line"
echo "              "

sed -n '1p' $fileName
echo "================================================================="


echo "#reading lines from 1 to 4"
echo "              "

sed -n '1,4p' $fileName
echo "================================================================"


echo "#reading lines 3, 7"
echo "              "
sed -ne '3p' -ne '7p' $fileName
echo   "===================================================================="

    else
    echo "$fileName doesn't exist"
fi




[prabhucloudxlab@cxln4 ~]$ sh hello.sh
enter filename to substitute using sed
filegrep.txt
#reading 1st line
unix is great os. unix is opensource. unix is free os.
=========================================================================================
#reading lines from 1 to 4
unix is great os. unix is opensource. unix is free os.
learn operating system.
Unix linux which one you choose.
uNix is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful.
=========================================================================================
#reading lines 3, 7
Unix linux which one you choose.
ThIs Is MAC 4000
=========================================================================================