LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-16-2003, 10:37 AM   #1
jeempc
Member
 
Registered: Mar 2003
Location: Ann Arbor, MI
Distribution: Slackware 10.1
Posts: 119

Rep: Reputation: 15
Text Utils


Hello. I have a text file that I want to cut in half, possibly 3rds. I cannot loose any information and will need to be able to verify that fact.
Basically, I have a large text file that I need to import into an access database. The problem is that once it is imported it is too big to do any type changing. So I need to break it up, do my changes, then appened the pieces into one database table.
I am thinking I can do this with head, tail, cat or something similar.
Is there a command that says find the length of this file and output the first half.
Jim
 
Old 05-16-2003, 10:48 AM   #2
bentz
Member
 
Registered: Mar 2003
Distribution: Fedora, Mac OSX
Posts: 362

Rep: Reputation: 30
Try 'split'.
 
Old 05-16-2003, 02:09 PM   #3
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
wc -l will tell you the number of lines in a file
head -n 'n' will print the first 'n' lines of a file to the screen
tail -n 'n' will print the last 'n' lines of a file to the screen

so string together with some pipes:
run wc to get number of lines, then divide in half (or by three), then run that figure as the argument to head -n
 
Old 05-16-2003, 06:09 PM   #4
jeempc
Member
 
Registered: Mar 2003
Location: Ann Arbor, MI
Distribution: Slackware 10.1
Posts: 119

Original Poster
Rep: Reputation: 15
Thanks. That is what I was looking for. I just didn't have time to search through man pages. I have a deadline at my job and am delving into unknown territory.
You saved me much time and headaches. I am just learning about processing text and with so many ways to do things a good solid answer is very nice.
I am currently learning Unix tools and Scripts, Perl, C and my head is full of possibilities.
I look forward to contributing and answering others questions in the future.
Thanks again.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Utils Questions ToothlessRebel Linux - Newbie 2 11-28-2004 05:24 AM
wireless utils maxware Linux - Wireless Networking 3 10-14-2004 09:03 AM
Regarding db4 utils moorman Red Hat 1 09-28-2004 10:42 PM
Bootsplash utils vavoem Linux - Software 1 09-14-2004 12:56 PM
Misc Utils Ben Sytko Linux - Software 4 03-11-2004 02:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:11 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
Open Source Consulting | Domain Registration