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 delete one line in a file in a loop

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-15-09, 07:08
anubhav2020 anubhav2020 is offline
Registered User
 
Join Date: Jul 2009
Posts: 2
How to delete one line in a file in a loop

Hi there,
I am very new to UNIX,

I have problem. I have file in the following format.
20080101,1234
20080102,2345
20080103,3456
20090101,1245
20090102,1534
....
...

As part ot automating a process, i am suppose to read the first line and process the first cycle(20080101). Upon completion, the first line has to be deleted and then the process should start with the second cycle(the first line after deletion, 20080102).

Please, can some one help.
Reply With Quote
  #2 (permalink)  
Old 07-15-09, 07:25
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,448
Wouldn't it be easier to delete the entire input file after you finish processing all lines?
Reply With Quote
  #3 (permalink)  
Old 07-15-09, 07:34
anubhav2020 anubhav2020 is offline
Registered User
 
Join Date: Jul 2009
Posts: 2
As i said, i am newbie in UNIX. Please suggest how i can do that.
Reply With Quote
  #4 (permalink)  
Old 07-15-09, 10:30
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,448
You would use the while command to organize a loop, the read command to read each line, and the rm command to delete the file when done.
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