If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > How to cut a line in a text file?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-09-04, 12:08
tanboonhoe tanboonhoe is offline
Registered User
 
Join Date: Feb 2004
Posts: 16
Red face How to cut a line in a text file?

My requirement is to process each line in a text file (raw data). I believe I need to cut each line starting from the first line and follow by the next line until end of file. Each line cut will be appended to a temp file for manupulation before combining them eventually into a text file. Would appreciate for your help. Thanks.
Reply With Quote
  #2 (permalink)  
Old 02-09-04, 12:38
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
Join Date: Jun 2002
Location: UK
Posts: 525
Re: How to cut a line in a text file?

Quote:
Originally posted by tanboonhoe
My requirement is to process each line in a text file (raw data). I believe I need to cut each line starting from the first line and follow by the next line until end of file. Each line cut will be appended to a temp file for manupulation before combining them eventually into a text file. Would appreciate for your help. Thanks.
Sounds a bit crazy to me. What's wrong with awk or sed for the job? Can you elaborate on your requirements?

Last edited by Damian Ibbotson; 02-09-04 at 12:55.
Reply With Quote
  #3 (permalink)  
Old 02-09-04, 21:02
tanboonhoe tanboonhoe is offline
Registered User
 
Join Date: Feb 2004
Posts: 16
Re: How to cut a line in a text file?

Quote:
Originally posted by Damian Ibbotson
Sounds a bit crazy to me. What's wrong with awk or sed for the job? Can you elaborate on your requirements?
I just want to cut each line in a text file starting from the first line until end of the file so that I can process the content in the record separately. I need to know as well how to move the pointer to the next line until end of file. FYI, I'm new in Shell scripts and awk and sed may be new to me.
Reply With Quote
  #4 (permalink)  
Old 02-10-04, 03:30
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
With shell you can do :
Code:
while read record
do
    echo $record
done < input_file
With awk :
Code:
awk '{ print tolower($0) }' input_file
Read post How to split one single text in multiple files?
__________________
Jean-Pierre.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On