LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to get the mid point (middle line ) of file, provided the length of file unknown (http://www.linuxquestions.org/questions/linux-newbie-8/how-to-get-the-mid-point-middle-line-of-file-provided-the-length-of-file-unknown-4175415746/)

vaibhavs17 07-09-2012 02:53 PM

how to get the mid point (middle line ) of file, provided the length of file unknown
 
I am able to get the length of file but not able to get the mid(middle) line of file in the same command.

>>tt=`wc -l resume.doc | cut -f1 -d ' '`;
>>echo $tt
6

vaibhavs17 07-09-2012 03:53 PM

I have tried this
>>tt=`wc -l temp.txt | cut -f1 -d ' '`;sed -n "`expr $tt / 2 - 4`,`expr $tt / 2` p" temp.txt

can we have better solution?


All times are GMT -5. The time now is 12:37 AM.