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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
![Reply](https://www.linuxquestions.org/questions/images/buttons/reply.gif) |
05-16-2003, 11:37 AM
|
#1
|
Member
Registered: Mar 2003
Location: Ann Arbor, MI
Distribution: Slackware 10.1
Posts: 119
Rep:
|
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
|
|
|
05-16-2003, 11:48 AM
|
#2
|
Member
Registered: Mar 2003
Distribution: Fedora, Mac OSX
Posts: 362
Rep:
|
Try 'split'.
|
|
|
05-16-2003, 03:09 PM
|
#3
|
Senior Member
Registered: Nov 2002
Location: British Columbia, Canada
Distribution: Gentoo x86_64; FreeBSD; OS X
Posts: 3,764
Rep:
|
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
|
|
|
05-16-2003, 07:09 PM
|
#4
|
Member
Registered: Mar 2003
Location: Ann Arbor, MI
Distribution: Slackware 10.1
Posts: 119
Original Poster
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 07:52 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|