Sponsored Content
Full Discussion: sed command to overwrite
Top Forums Shell Programming and Scripting sed command to overwrite Post 302426538 by mhdmehraj on Wednesday 2nd of June 2010 07:12:00 AM
Old 06-02-2010
sed command to overwrite

Hi,

i have a file ver.sql with the following contents , Here i need to put a in the next line of END statment .
So iam doing the following

Code:
D:\>type ver.sql
begin
ctxsys.driimp.set_value('STOP_WORD','yours');
ctxsys.driimp.set_object('STORAGE','BASIC_STORAGE',2);
ctxsys.driimp.set_value('R_TABLE_CLAUSE','lob (data) store as (cache)');
ctxsys.driimp.set_value('I_INDEX_CLAUSE','compress 2');
commit;
COMMIT;  END;

D:\>sed "s@END;@ END;\n/@g" ver.sql >>ver.log

D:\>type ver.log
begin
ctxsys.driimp.set_value('STOP_WORD','yours');
ctxsys.driimp.set_object('STORAGE','BASIC_STORAGE',2);
ctxsys.driimp.set_value('R_TABLE_CLAUSE','lob (data) store as (cache)');
ctxsys.driimp.set_value('I_INDEX_CLAUSE','compress 2');
commit;
COMMIT;   END;
/

It works fine now , Here in my source file (ver.sql ) , if i already get a slash (/) after the end statment, then it need to overwrite it. But in my case it is appending in the next line ..

Code:
D:\>type ver.sql
begin
ctxsys.driimp.set_value('STOP_WORD','yours');
ctxsys.driimp.set_object('STORAGE','BASIC_STORAGE',2);
ctxsys.driimp.set_value('R_TABLE_CLAUSE','lob (data) store as (cache)');
ctxsys.driimp.set_value('I_INDEX_CLAUSE','compress 2');
commit;
COMMIT;  END;
/

D:\>sed "s@END;@ END;\n/@g" ver.sql >>ver.log

D:\>type ver.log
begin
ctxsys.driimp.set_value('STOP_WORD','yours');
ctxsys.driimp.set_object('STORAGE','BASIC_STORAGE',2);
ctxsys.driimp.set_value('R_TABLE_CLAUSE','lob (data) store as (cache)');
ctxsys.driimp.set_value('I_INDEX_CLAUSE','compress 2');
commit;
COMMIT;   END;
/
/


how to overwrite this?

---------- Post updated at 06:12 AM ---------- Previous update was at 05:40 AM ----------

Any updates please

Last edited by pludi; 06-02-2010 at 07:49 AM.. Reason: code tags, please...
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Overwrite

if i want to pipe output to a file, say, cat abc.dat > abc.txt, how do i make it replace the existing file? (9 Replies)
Discussion started by: Duckman
9 Replies

2. UNIX for Dummies Questions & Answers

overwrite problem

Hi im using the following to copy a file to a directory, the user being prompted to overwrite if the file already exists in that directory, cp -i myfile /home/brief/bin2 but this reveals the path of the directory when being prompted to overwrite (below) cp: overwrite... (2 Replies)
Discussion started by: ali999
2 Replies

3. Shell Programming and Scripting

Loop with sed command to replace line with sed command in it

Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line. ... (1 Reply)
Discussion started by: cbo0485
1 Replies

4. UNIX for Dummies Questions & Answers

overwrite problem

my script is: awk '...mycode...' file1.txt > file2.txt and i want to overwrite file2.txt eachtime I run this script. but it says:File exists! :( I have tried awk '...mycode...' file1.txt >| file2.txt but it again says:Missing name for redirect! :confused::confused: what is this? (2 Replies)
Discussion started by: gc_sw
2 Replies

5. Shell Programming and Scripting

Field overwrite using sed or awk

Is there a way to overwrite a specific field (i.e. line 2 field 3 without getting its contents). For example I would like to simply have a compatible Solaris 10 command line that replaces line 2 field 3 with contents of a variable. I would like to use SED or AWK if possible, but other suggestions... (1 Reply)
Discussion started by: thibodc
1 Replies

6. Shell Programming and Scripting

Better to Delete or Overwrite

Hello All, I had just a question about my Bash Script I'm currently writing. The script I have writes some text to a output file. After I write to the output file I send the file to another server to do some stuff with it. After the file sends in the script, I don't need the output/txt... (4 Replies)
Discussion started by: mrm5102
4 Replies

7. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies

8. Shell Programming and Scripting

Overwrite bash system command

Hello, The problem I met is the conflict between the default command /usr/bin/sometools, which is an very old version at system setup, and an updated one I have installed in $HOME/download-software/sometools How do I tell a third program to use the customized sometools instead of the default... (6 Replies)
Discussion started by: yifangt
6 Replies

9. SCO

Command line overwrite

is there a way to overwrite what I have typed in rather than having to hit enter and re enter the command? SCO UNIX 3.2.4.2 (14 Replies)
Discussion started by: steveo314
14 Replies
SQL::Translator::Parser::SQLite(3pm)			User Contributed Perl Documentation		      SQL::Translator::Parser::SQLite(3pm)

NAME
SQL::Translator::Parser::SQLite - parser for SQLite SYNOPSIS
use SQL::Translator; use SQL::Translator::Parser::SQLite; my $translator = SQL::Translator->new; $translator->parser("SQL::Translator::Parser::SQLite"); DESCRIPTION
This is a grammar for parsing CREATE statements for SQLite as described here: http://www.sqlite.org/lang.html CREATE INDEX sql-statement ::= CREATE [TEMP | TEMPORARY] [UNIQUE] INDEX index-name ON [database-name .] table-name ( column-name [, column-name]* ) [ ON CONFLICT conflict-algorithm ] column-name ::= name [ ASC | DESC ] CREATE TABLE sql-command ::= CREATE [TEMP | TEMPORARY] TABLE table-name ( column-def [, column-def]* [, constraint]* ) sql-command ::= CREATE [TEMP | TEMPORARY] TABLE table-name AS select-statement column-def ::= name [type] [[CONSTRAINT name] column-constraint]* type ::= typename | typename ( number ) | typename ( number , number ) column-constraint ::= NOT NULL [ conflict-clause ] | PRIMARY KEY [sort-order] [ conflict-clause ] | UNIQUE [ conflict-clause ] | CHECK ( expr ) [ conflict-clause ] | DEFAULT value constraint ::= PRIMARY KEY ( name [, name]* ) [ conflict-clause ]| UNIQUE ( name [, name]* ) [ conflict-clause ] | CHECK ( expr ) [ conflict-clause ] conflict-clause ::= ON CONFLICT conflict-algorithm CREATE TRIGGER sql-statement ::= CREATE [TEMP | TEMPORARY] TRIGGER trigger-name [ BEFORE | AFTER ] database-event ON [database-name .] table-name trigger-action sql-statement ::= CREATE [TEMP | TEMPORARY] TRIGGER trigger-name INSTEAD OF database-event ON [database-name .] view-name trigger-action database-event ::= DELETE | INSERT | UPDATE | UPDATE OF column-list trigger-action ::= [ FOR EACH ROW | FOR EACH STATEMENT ] [ WHEN expression ] BEGIN trigger-step ; [ trigger-step ; ]* END trigger-step ::= update-statement | insert-statement | delete-statement | select-statement CREATE VIEW sql-command ::= CREATE [TEMP | TEMPORARY] VIEW view-name AS select-statement ON CONFLICT clause conflict-clause ::= ON CONFLICT conflict-algorithm conflict-algorithm ::= ROLLBACK | ABORT | FAIL | IGNORE | REPLACE expression expr ::= expr binary-op expr | expr like-op expr | unary-op expr | ( expr ) | column-name | table-name . column-name | database-name . table-name . column-name | literal-value | function-name ( expr-list | * ) | expr (+) | expr ISNULL | expr NOTNULL | expr [NOT] BETWEEN expr AND expr | expr [NOT] IN ( value-list ) | expr [NOT] IN ( select-statement ) | ( select-statement ) | CASE [expr] ( WHEN expr THEN expr )+ [ELSE expr] END like-op::= LIKE | GLOB | NOT LIKE | NOT GLOB AUTHOR
Ken Youens-Clark <kclark@cpan.org>. SEE ALSO
perl(1), Parse::RecDescent, SQL::Translator::Schema. perl v5.14.2 2012-01-18 SQL::Translator::Parser::SQLite(3pm)
All times are GMT -4. The time now is 08:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy