10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
My input files is like this
axis1 0 1 10
axis2 0 1 5
axis1 1 2 -4
axis2 2 3 -3
axis1 3 4 5
axis2 3 4 -1
axis1 4 5 -6
axis2 4 5 1
Now, these are my following tasks
1. Print a first column for every two rows that has the same value followed by a string.
2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies
2. Shell Programming and Scripting
Hi,
I have a requirement to search for a pattern in each line in a file and remove the in between words till the 3rd occurrence of double quote (").
Ex: CREATE TABLE "SCHEMANAME"."AMS_LTV_STATUS"
(Note: "SCHEMANAME" may changes for different schemas. Its not a fixed value)
I need to... (2 Replies)
Discussion started by: satyaatcgi
2 Replies
3. Shell Programming and Scripting
Hi
I have 5 columns like this
a b c d e
f g h i j
k l m n o
From 2nd column till the 5th column of every record, I would like to transpose them as rows, so my output file contains only one row
a
b
c
d
e
f
g
h
i
j (9 Replies)
Discussion started by: jacobs.smith
9 Replies
4. Shell Programming and Scripting
Is there an awk script that can easily perform the following operation?
I have a data file that is in the format of
1944-12,5.6
1945-01,9.8
1945-02,6.7
1945-03,9.3
1945-04,5.9
1945-05,0.7
1945-06,0.0
1945-07,0.0
1945-08,0.0
1945-09,0.0
1945-10,0.2
1945-11,10.5
1945-12,22.3... (3 Replies)
Discussion started by: ncwxpanther
3 Replies
5. Shell Programming and Scripting
I have an awk script to find the maximum value of the 2nd column of a 2 column datafile, but I need to find the top 5 maximum values of the 2nd column.
Here is the script that works for the maximum value.
awk 'BEGIN { subjectmax=$1 ; max=0} $2 >= max {subjectmax=$1 ; max=$2} END {print... (3 Replies)
Discussion started by: ncwxpanther
3 Replies
6. Shell Programming and Scripting
I have n files and I am using cat to combine them in to one.
Before that simply add the name of the output file to 4th column and then print the output. Is it possible ?
input1
chr start end name 0 + key
input2
chr start end name 0 + key
inputn... (1 Reply)
Discussion started by: quincyjones
1 Replies
7. Shell Programming and Scripting
Hi everyone, this is my first post here, I hope someone can help me.
I have a file which I need to delete characters '_F3' from the end of the text in the first column. The problem is that the characters may also occur elsewhere in the file (i.e. second columns onwards). I tried sed (thinking I... (6 Replies)
Discussion started by: hlwright
6 Replies
8. Shell Programming and Scripting
Hello UNIX experts,
I have 124 text files in a directory. I want to extract the 45678th line of all the files sequentialy by file names. The extracted lines should be printed in the output file on seperate lines.
e.g. The input Files are one.txt, two.txt, three.txt, four.txt
The cat of four... (1 Reply)
Discussion started by: yogeshkumkar
1 Replies
9. Shell Programming and Scripting
All,
i need a script which can zip the all files which are in directories and its subdirectories
for example:
dir1 contains file1,file2,dir1a,dir1b
now dir1a also contains fil11,fil12 ,dirab
so script should look for files in dir or sub dir till files not found and... (2 Replies)
Discussion started by: vijays3
2 Replies
10. Shell Programming and Scripting
Dear All
I have a file like this
112534554
446538656
444695656
225696966
226569744
228787874
113536566
443533535
222564552
115464656
225445345
225533234
I want to cut the file into different parts where the first two columns are '11' . The first two columns will be either... (3 Replies)
Discussion started by: anoopvraj
3 Replies
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)