Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-09-2012, 02:53 PM   #1
Registered: Mar 2009
Posts: 51

Rep: Reputation: 1
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
Old 07-09-2012, 03:53 PM   #2
Registered: Mar 2009
Posts: 51

Original Poster
Rep: Reputation: 1
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?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
access a file line by line, and check the length of each line. ddebbie90 Programming 1 02-13-2011 03:31 PM
file type for the Linux kernel image file, (vmlinuz) is unknown james2b Linux - Software 6 11-12-2009 03:39 PM
bash/sed/awk fill each line in text file with space to fixed length khairil Programming 11 01-09-2008 06:28 AM
Detect length of line in file craigjward Programming 9 12-12-2007 12:13 AM
trying to redirect text to a file to cat at later point. says file doesn't exist. dr_zayus69 Programming 1 10-02-2005 09:10 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:16 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration