LinuxQuestions.org
Visit Jeremy's Blog.
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-06-2008, 10:40 PM   #1
cghcgh
Member
 
Registered: Mar 2008
Posts: 69

Rep: Reputation: 15
File content too long


Hi,

I have a file that is for example 10000 lines. I want to put the first 100 lines into a file called 'A' and the rest into a file called 'B'. The problem is that when i vi or view it, it will say the file is too long. The content for file B is 1 single line...so i think it's not safe to more the file then copy the content over and join the lines up. Pls kindly advise.

THanks.
 
Old 07-06-2008, 10:59 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
10,000 lines is not too long. It sounds more like this is a DOS file that has different line terminators, so it looks like one very long line.

If this is so, convert with dos2unix.

Once that is done, you can do:

head -100 yourfile > A
sed -n '101,$p' yourfile > B

Last edited by Mr. C.; 07-06-2008 at 11:32 PM.
 
Old 07-06-2008, 11:07 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,724

Rep: Reputation: 2121Reputation: 2121Reputation: 2121Reputation: 2121Reputation: 2121Reputation: 2121Reputation: 2121Reputation: 2121Reputation: 2121Reputation: 2121Reputation: 2121
Small typo there methinks - p'haps "tail -n +101 ..." might be better (as in easier understood).
 
Old 07-06-2008, 11:33 PM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Oops, fixed the 11 -> 101 in the edit above.

I picked sed just to show the usage of another tool.
 
  


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
how to create a new file including content from reading another file !? silverhand Programming 2 10-06-2007 04:33 PM
Show file Content on File Select HTML stranger_6_7 Linux - General 4 09-24-2007 11:52 PM
delete file-content ovince Programming 6 04-17-2007 03:44 AM
changing the content of file in spec file dsubbarao Linux - Newbie 7 01-30-2007 06:41 AM
find the same content in the file ust Linux - Newbie 5 03-23-2005 03:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:44 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration