LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-19-2010, 10:43 AM   #1
gartura
LQ Newbie
 
Registered: Nov 2009
Posts: 6

Rep: Reputation: 0
Need A Script That Reads 70 Lines and Redirects Them


all,
i have a file that contains 100 ligns, i need to write a script that read 70 lignes and redirect those 70 ligns to another files and these 70ligns have to be erased in the first file

when i write this command
head -70 somefile.txt>test.txt
or

sed -n 70p somefile.txt>test.txt

i have these 70 lines in the text.txt files
but these 70 lines have to be deleted inthe first file somefile.txt

please help me

Last edited by gartura; 07-20-2010 at 09:38 AM.
 
Old 07-19-2010, 12:17 PM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Gartura - I have created a new thread for you to address your problem.
 
Old 07-19-2010, 12:48 PM   #3
HasC
Member
 
Registered: Oct 2009
Location: South America - Paraguay
Distribution: Debian 5 - Slackware 13.1 - Arch - Some others linuxes/*BSDs through KVM and Xen
Posts: 329

Rep: Reputation: 55
fine. now, what you've done until now? show us some code
 
Old 07-19-2010, 01:06 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by gartura View Post
all,
i have a file that contains 100 ligns, i need to write a script that read 70 lignes and redirect those 70 ligns to another files and these 70 ligns have to be erase in the first file.

please help me
Ok...we'll be glad to HELP. That means, you write the script, and post it, telling us where you're getting stuck. But we're not going to write scripts for you.

There are many bash scripting tutorials you can find via Google. You can also read the man pages for "head" and "tail", both of which can be used here to quick-and-dirty a script to do what you want.

And by the way, it's spelled "lines".
 
Old 07-19-2010, 02:56 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
An even bigger hint: Look at the addressing functionality in SED. Really good SED tutorial here:
http://www.grymoire.com/Unix/Sed.html
 
Old 07-19-2010, 07:39 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by pixellany View Post
An even bigger hint: Look at the addressing functionality in SED. Really good SED tutorial here:
http://www.grymoire.com/Unix/Sed.html
Nice one...going to bookmark that...
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script that reads files in directory and processes them KayakJim Linux - Newbie 2 01-22-2010 09:53 AM
Shell script that reads from parameters file carters2 Linux - Newbie 4 11-04-2009 08:24 AM
FTP script with user prompting/redirects/renaming tazer92 Linux - Newbie 1 05-13-2009 12:11 PM
php script that reads content from text file adrianno2 Programming 3 07-21-2008 01:14 AM
How to create a shell script that reads something from stdin? ricky_ds Programming 2 05-17-2005 05:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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