LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-21-2009, 02:34 PM   #1
clstanton
LQ Newbie
 
Registered: May 2008
Posts: 27

Rep: Reputation: 0
spliting a text file into several parts by line count


I have a utility that works with files. The utility is crashing at after about 120 files. The input to the utility is a file containing a filelist. I want to cut the file with the file names in it to seperate files containing about one hundred or so.

My thought was to determine the number of lines/100 and then use head and delete to create temporary files to run the utility multiple times to prevent the crash.

When I tried to create a variable using the wc -l command the output gives me the number of total lines but it also includes the filename of the input file. ( 873 Filename.txt ) I can not figure out how to remove the Filename.txt from the variable.

Any suggestions to any or all of this would be greatly appreciated.

Thanks
Chris
 
Old 09-21-2009, 02:37 PM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
man split, specifically:
Code:
split -l 100 input_file
Check the man page for options on getting more sensible output filenames.
 
Old 09-21-2009, 02:49 PM   #3
clstanton
LQ Newbie
 
Registered: May 2008
Posts: 27

Original Poster
Rep: Reputation: 0
I was not aware of the split command

Thanks
 
  


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
bash: how to split a text file in two unequal parts Humbro Programming 7 11-23-2007 08:15 AM
Count occurances of a string in a text file MicahCarrick Linux - Software 1 06-24-2006 05:25 PM
Copying parts of a text file austen77 Linux - Newbie 3 09-01-2005 10:56 PM
Count number of line in a file. philipina Programming 7 03-18-2004 06:04 PM


All times are GMT -5. The time now is 10:22 AM.

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