how to read a file till it encounters a blank line


 
Thread Tools Search this Thread
Contact Us Post Here to Contact Site Administrators and Moderators how to read a file till it encounters a blank line
# 1  
Old 11-26-2007
how to read a file till it encounters a blank line

Hi ,
I want to read a file starting with "*" up to till it encounters a blank line and to redirect this output to a different file.Plz suggest how to write a script for this.

e.g:-
* PK Sent Email (11.23)
CALYPSO 1243215 9116457 NEW TRAD FAILED Nov 23 2007 9:34AM OASYS: DPS: SINGCORP invalid use of FirmA

* PK sent email (11.20)
CALYPSO 1238957 9088029 ONRUNDEL FAILED Nov 20 2007 8:04AM OASYS: Unable to find CUSTOMER account BS


Here I need to read from * until it encounters a blank line.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combine multiline to one line till a blank line

Hello, I have a file as :- ABC DEF GHI JKL <BlankLine> MNO PQR STU VWX <BlankLine> YZA I need it as below:- ABCDEFGHIJKL; MNOPQRSTUVWX; (3 Replies)
Discussion started by: jassi10781
3 Replies

2. Shell Programming and Scripting

Bash script to read a file from particular line till required line and process

Hi All, Am trying to write wrapper shell/bash script on a utility tool for which i need to pass 2 files as arugment to execute utility tool. Wraper script am trying is to do with above metion 2 files. utility tool accepts : a. userinfo file : which contains username b. item file : which... (2 Replies)
Discussion started by: Optimus81
2 Replies

3. UNIX for Dummies Questions & Answers

When reading a csv file, counter to read 20 lines and wait for minute then read next 20 till end

Hello All, i am a newbie and need some help when reading a csv file in a bourne shell script. I want to read 10 lines, then wait for a minute and then do a reading of another 10 lines and so on in the same way. I want to do this till the end of file. Any inputs are appreciated ... (3 Replies)
Discussion started by: victor.s
3 Replies

4. Shell Programming and Scripting

Awk script to match pattern till blank line

Hi, I need to match lines after a pattern, upto the first blank line. Searched in web and some forums but coulnt find the answer. where <restart_step> = 10 -- Execute query 20 -- Write the contents to the Oracle table 30 -- Writing Contents to OUTPUT... (7 Replies)
Discussion started by: justchill
7 Replies

5. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

6. Shell Programming and Scripting

[Solved] Read a line from one string till to another.... Unix scripting..

So i have a file which contains paths to JPG images separated by a space. I have to separate them each path to another file. So, I have to search all strings that start from /home/ and ends with .jpg or .png Then write each one to another file... Can you please help me on doing this???:cool: (11 Replies)
Discussion started by: hakermania
11 Replies

7. UNIX for Dummies Questions & Answers

Read lines till a blank line is encountered

Hi, I have reached at a specified offset from the start of file. My requirement is that I want to read only those lines, which have the string READ / ALTER / UPDATE. As soon as, none of these literals are found in the subsequent line, I want to stop reading. Is there any feature of grep which... (1 Reply)
Discussion started by: saurabhsinha23
1 Replies

8. UNIX for Dummies Questions & Answers

how to read a file till it encounters a blank line

Hi , I want to read a file starting with "*" up to till it encounters a blank line and to redirect this output to a different file.Plz suggest how to write a script for this. e.g:- * PK Sent Email (11.23) CALYPSO 1243215 9116457 NEW TRAD FAILED Nov 23 2007 9:34AM OASYS: DPS: SINGCORP invalid... (1 Reply)
Discussion started by: adityam
1 Replies

9. Shell Programming and Scripting

how to read a file till it encounters a blank line

Hi , I want to read a file starting with "*" up to till it encounters a blank line and to redirect this output to a different file.Plz suggest how to write a script for this. e.g:- * PK Sent Email (11.23) CALYPSO 1243215 9116457 NEW TRAD FAILED Nov 23 2007 9:34AM OASYS: DPS: SINGCORP invalid... (1 Reply)
Discussion started by: adityam
1 Replies

10. Shell Programming and Scripting

need to read a file and keep waiting till it satisfies some condition

In my script i am writing to a counter file the no of processes i had started, that is each time i start a process, i will increment the content of counter file and also when the process ends i will decrement the content of the file. after this i do some other activities, by now i want to... (1 Reply)
Discussion started by: senthilk615
1 Replies
Login or Register to Ask a Question
Jifty::Manual::Upgrading(3pm)				User Contributed Perl Documentation			     Jifty::Manual::Upgrading(3pm)

NAME
Jifty::Manual::Upgrading - How-to change your application database over time DESCRIPTION Jifty provides a way for you to upgrade the database schema and data of your application between versions. If all you are doing is adding new models or columns to existing models Jifty will do the upgrade almost automatically. If more extensive changes are required you need to write some code to tell Jifty what to do. TERMINOLOGY
Be sure you know the following terms before reading this document: o "schema" in Jifty::Manual::Glossary o "schema version" in Jifty::Manual::Glossary o "database version" in Jifty::Manual::Glossary HOW TO
General Instructions For all of these actions, the the database version stored in your Jifty configuration is significant. See the value stored in etc/config.yml at: framework: Database: Version: 0.0.1 Make all your code changes using the version number you are going to use. Once you have finished updating your code and are ready to test, bump the version stored in etc/config.yml to match the new version you are going to use. If you are writing tests as you go (shame on you if you aren't!), you should be able to run: perl Makefile.PL make make test to test the latest version and check for problems. Once you are sure you've worked out the kinds, you may perform the actual upgrade by running: bin/jifty schema --setup This will take care of the work of adding any new columns and models, dropping old columns, and running any upgrade scripts you have scheduled. Basic column and model operations Adding a new model Create your model just as you normally would: bin/jifty model --name MyModel Then, you need to tell Jifty at which version of your application the model was created. To do this add a since sub to your new model class. sub since { '0.0.5' } Adding a new column to an existing model When you have an existing model and decide that you need to add another column to it you also need to tell Jifty about this. This is done by using "since" as well. However, the "since" goes into the column definition itself. column created_by => refers_to Wifty::Model::User, since '0.0.20'; Dropping a column from a model CAUTION: Be aware that all the data that was stored in this column will be destroyed at upgrade if you follow this procedure. If you no longer need a particular column in your model, you can have it dropped by setting the "till" property on your column definition. column extra_info type is 'text', label is 'Extra info', till '0.0.13'; The version you use for "till" is the version the drop is effective. In the example above, the "extra_info" column will be available in version 0.0.12, but not in version 0.0.13. This column will be dropped from the schema at the next upgrade, which will destroy all data stored in that column. TODO Dropping a model Data migration and schema changes If a file called Upgrade.pm exists in your application it will be run by "jifty schema --setup". Upgrade.pm can be used to make any schema changes or to manipulate your applications data. At the very least your Upgrade.pm should contain the following: package MyApp::Upgrade; use base qw(Jifty::Upgrade); use Jifty::Upgrade qw( since rename ); since '0.6.1' => sub { .... }; The "since" function is where you do all the work. Each "since" will be run in version order until the application is up to date. Renaming a column To rename a column, you need to make sure that your schema and upgrade script both cooperate in the process. Your schema will record changes to your model API and the upgrade script will tell Jifty about the rename. The old column name needs to marked with "till" to notify Jifty that the column name no longer exists. The new column name needs to marked with "since" to notify Jifty that a column by the new name exists. Here we are renaming "zip" to "postcode": column zip => type is 'text', label is 'ZIP code', till '0.6.1'; column postcode => type is 'text', label is 'Postal code', since '0.6.1'; Notice that both "since" and "till" have the same version number set. This is the version number the change will take place. Before you upgrade, though, you must tell Jifty that a rename is happening here, which is done in your upgrade script: use MyApp::Upgrade; use base qw(Jifty::Upgrade); use Jifty::Upgrade qw( since rename ); since '0.6.1' => sub { rename( table => 'MyApp::Model::User', column => 'zip', to => 'postcode' ); }; Migrating data You can perform any action you want inside the "since" blocks of your upgrade script. In the case of data migration, you might want to convert your data from one form to another. For example, let's say our users always gave us "first_name" and "last_name" before, but we've added a new column "display_name" which will normally contain their name in "last, first" format, but could be customized per-account. We want to go ahead and initialize this new column during the upgrade. In your upgrade script, you could add: since '0.2.4' => sub { my $users = MyApp::Model::UserCollection->new( current_user => Jifty->app_class('CurrentUser')->superuser ); $users->unlimit; while (my $user = $users->next) { # error checks may save you from hours of debugging my ($status, $msg) = $user->set_display_name( join(', ', $user->last_name, $user->first_name) ); Jifty->log->error("Couldn't change user record: $msg") unless $status; } }; Note that collection created using super user to pass ACL checks and other restrictions, if your models are protected from super user then you may have problems. See also Jifty::Manual::AccessControl. SEE ALSO
Jifty::Upgrade, Jifty::Script::Schema, Jifty::Manual::Models, Jifty::Manual::Tutorial, Jifty::Manual::Glossary perl v5.14.2 2010-09-25 Jifty::Manual::Upgrading(3pm)