02-06-2008
In Help, Substitute Text ...
i'm writing a script that will extract and substitute a certain part of a data.
i'm having trouble with the substituting part ...
Here's my data looks like:
01/01/08-001-23:46:18-01/01/08-23:50:43
01/01/08-003-23:45:19-01/01/08-23:55:49
01/01/08-005-23:52:18-01/01/08-23:58:52
i want to change the second column i.e. 001,003,005 to:
CODE01 for 001, CODE03 for 003 and CODE05 for 005. so that it will look like this ...
01/01/08-CODE01-23:46:18-01/01/08-23:50:43
01/01/08-CODE03-23:45:19-01/01/08-23:55:49
01/01/08-CODE05-23:52:18-01/01/08-23:58:52
i have separate a file for the list of codes to be substituted. i tried using sed, but can't figure out how.
i'm on: using csh
SunOS 5.8 Generic_108528-22 sun4u sparc SUNW,UltraAX-MP
oh btw, im new here =D
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Another enigma (for me)
Using VI I edit some files in which I want to erase many lines I don't need anymore
usually I do something like that::%s/line_to_suppress//g
and it is doing fine
but in this case, the pattern to erase contains some special characters
so I do it like... (9 Replies)
Discussion started by: Lomic
9 Replies
2. Shell Programming and Scripting
well i have this file here:
<XML>
<pregate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<system_c>HPREGATE</system_c>
<trans_c>HSPG</trans_c>
<trans_dt>20060105161333</trans_dt>
<user_id_m></user_id_m>
<func_c>C</func_c>
</pregate>
</XML>
i want to... (2 Replies)
Discussion started by: forevercalz
2 Replies
3. UNIX for Dummies Questions & Answers
I know in vi you can do
:%s/replaceme/withthis/
but if i want to find all lines say without a # at the begining and I want to put it in how would that command be formatted? I can't figure it out for the life of me.
#comment
blah1
hey1
grrr1
#comment
#blah1
#hey1
#grrr1 (5 Replies)
Discussion started by: kingdbag
5 Replies
4. Shell Programming and Scripting
Hi,
I have query terms like this:
a) apple bannana
b) apple bannana AND chickko
c) "milk shake" OR Graphes orange
whereever there is space substitue with AND operator.
I tried like this: (2 Replies)
Discussion started by: vanitham
2 Replies
5. Shell Programming and Scripting
My question is how would I substitute for ceratain number of occurences in a line? If this is my input
rjohns BFSTDBS01 Standard Silver NPRO30DINCR 2 Client
Is it possible to change the first 3 occurences of space " " to a comma? (7 Replies)
Discussion started by: reggiej
7 Replies
6. Shell Programming and Scripting
Hi gurus,
I need help with shell script. I have various INSERT queries which inserts data into database. I want to insert 3rd column data into newline for one particular table. I have very time long txt file everytime and it have various INSERT/UPDATE queries but i have to done with it only one... (8 Replies)
Discussion started by: mirfan
8 Replies
7. Shell Programming and Scripting
using awk to substitute data in a column delimited text file
hello i would like to use awk to do the following calculation from the following snippet.
input file
C;2390 ;CV BOUILLOTTE 2L 2FACES NERVUREES ;1.00 ;3552612239004;13417 ;25 ;50 ; 12;50000 ; ; ... (3 Replies)
Discussion started by: iindie
3 Replies
8. UNIX for Dummies Questions & Answers
I usually use :
Code:
awk '{gsub(/xxx/,"yyy");print}'
to substitute xxx with yyy.
I have a problem substitute an expression like
Code:
x ' y
Because of the ( ' )
Any idea on how to get over this problem?
Thanks (2 Replies)
Discussion started by: cosmologist
2 Replies
9. UNIX for Dummies Questions & Answers
Hi there,
i am updating a file on UNIX and have many lines as per below :
listen:x:37:4:Network Admin:/usr/net/nls:
i would like to substitute from the :/usr to the end of the line.
so at the moment im using this :
:s/"\/$/ /g
but i get an error.can anyone help?
thank you (3 Replies)
Discussion started by: brian112
3 Replies
10. Programming
I need to substitute only comma with dot in string like this:
<strong>5,4</strong>but not sure how to do this.
This does not work:
text = sub('<strong>(,)</strong>', '<strong>(.)</strong>', text) (1 Reply)
Discussion started by: TiedCone
1 Replies
LEARN ABOUT DEBIAN
data::phrasebook::loader::text
Data::Phrasebook::Loader::Text(3pm) User Contributed Perl Documentation Data::Phrasebook::Loader::Text(3pm)
NAME
Data::Phrasebook::Loader::Text - Absract your phrases with plain text files.
SYNOPSIS
use Data::Phrasebook;
my $q = Data::Phrasebook->new(
class => 'Fnerk',
loader => 'Text',
file => 'phrases.txt',
);
# use default delimiters (:variable)
my $phrase = $q->fetch($keyword,{variable => 'substitute'});
# use Template Toolkit style delimiters
$q->delimiters( qr{ [% s* (w+) s* %] }x );
my $phrase = $q->fetch($keyword,{variable => 'substitute'});
DESCRIPTION
This loader plugin implements phrasebook patterns using plain text files.
Phrases can be contained within one or more dictionaries, with each phrase accessible via a unique key. Phrases may contain placeholders,
please see Data::Phrasebook for an explanation of how to use these. Groups of phrases are kept in a dictionary. In this implementation a
single file is one complete dictionary.
An example plain text file:
foo=Welcome to :my world. It is a nice :place.
Within the phrase text placeholders can be used, which are then replaced with the appropriate values once the get() method is called. The
default style of placeholders can be altered using the delimiters() method.
INHERITANCE
Data::Phrasebook::Loader::Text inherits from the base class Data::Phrasebook::Loader::Base. See that module for other available methods
and documentation.
METHODS
load
Given a "file", load it. "file" must contain a valid phrase map.
my $file = 'english.txt';
$loader->load( $file );
This method is used internally by Data::Phrasebook::Generic's "data" method, to initialise the data store.
To utilise the dictionary framework for a Plain Text phrasebook, the idea is to use a directory of files, where the directory is passed via
the "file" argument and the dictionary, the specific name of the file, is passed via the "dictionary" argument.
my $file = '/tmp/phrasebooks';
my $dictionary = 'english.txt';
$loader->load( $file, $dictionary );
get
Returns the phrase stored in the phrasebook, for a given keyword.
my $value = $loader->get( $key );
dicts
Having instantiated the "Data::Phrasebook" object class, and using the "file" attribute as a directory path, the object can return a list
of the current dictionaries available as:
my $pb = Data::Phrasebook->new(
loader => 'Text',
file => '/tmp/phrasebooks',
);
my @dicts = $pb->dicts;
or
my @dicts = $pb->dicts( $path );
keywords
Having instantiated the "Data::Phrasebook" object class, using the "file" and "dict" attributes as required, the object can return a list
of the current keywords available as:
my $pb = Data::Phrasebook->new(
loader => 'Text',
file => '/tmp/phrasebooks',
dict => 'TEST',
);
my @keywords = $pb->keywords;
or
my @keywords = $pb->keywords( $path, $dict );
Note that $path can either be the directory path, where $dict must be the specific file name of the dictionary, or the full path of the
dictionary file.
In the second instance, the function will not load a dictionary, but can be used to interrogate the contents of a known dictionary.
SEE ALSO
Data::Phrasebook.
SUPPORT
Please see the README file.
AUTHOR
Barbie, <barbie@cpan.org>
for Miss Barbell Productions <http://www.missbarbell.co.uk>.
COPYRIGHT AND LICENSE
Copyright (C) 2004-2010 Barbie for Miss Barbell Productions.
This module is free software; you can redistribute it and/or
modify it under the Artistic Licence v2.
perl v5.10.1 2010-08-31 Data::Phrasebook::Loader::Text(3pm)