LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 07-09-2012, 01:53 PM   #1
vaibhavs17
Member
 
Registered: Mar 2009
Posts: 49

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
6
 
Old 07-09-2012, 02:53 PM   #2
vaibhavs17
Member
 
Registered: Mar 2009
Posts: 49

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?
 
  


Reply


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 02:31 PM
file type for the Linux kernel image file, (vmlinuz) is unknown james2b Linux - Software 6 11-12-2009 02:39 PM
bash/sed/awk fill each line in text file with space to fixed length khairil Programming 11 01-09-2008 05:28 AM
Detect length of line in file craigjward Programming 9 12-11-2007 11:13 PM
trying to redirect text to a file to cat at later point. says file doesn't exist. dr_zayus69 Programming 1 10-02-2005 08:10 AM


All times are GMT -5. The time now is 03:05 PM.

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