Sponsored Content
Top Forums Shell Programming and Scripting Find and replace a string in group of sting Post 302594541 by gavemani on Tuesday 31st of January 2012 02:27:15 PM
Old 01-31-2012
Find and replace a string in group of sting

Hi,

1. I want to remove the line which contains "SUBPARTITION", but the condition is
if line has ends with "),"
replace with ,
else
delete the line

I was trying with the sed command i did get success

Sample content in the File :
Code:
NOLOGGING
    (SUBPARTITION AGGR_RSK_RST_00081118_NODE_1 VALUES(1) TABLESPACE RRDB_AGGR_RSK_RST_T_P2008, 
    SUBPARTITION AGGR_RSK_RST_00081118_NODE_2 VALUES(2) TABLESPACE RRDB_AGGR_RSK_RST_T_P2008), 
 PARTITION AGGR_RSK_RST_00081119 VALUES LESS THAN (TO_DATE(' 0008-11-19  00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    TABLESPACE RRDB_AGGR_RSK_RST_T_P2008
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    NOLOGGING
    (SUBPARTITION AGGR_RSK_RST_00081119_NODE_1 VALUES(1) TABLESPACE RRDB_AGGR_RSK_RST_T_P2008,
    SUBPARTITION AGGR_RSK_RST_00081119_NODE_2 VALUES(2) TABLESPACE RRDB_AGGR_RSK_RST_T_P2008),
PARTITION AGGR_RSK_RST_00081120 VALUES LESS THAN (TO_DATE(' 0008-11-20  00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    TABLESPACE RRDB_AGGR_RSK_RST_T_P2008

Ouptput should be :
Code:
NOLOGGING
  , 
 PARTITION AGGR_RSK_RST_00081119 VALUES LESS THAN (TO_DATE(' 0008-11-19  00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    TABLESPACE RRDB_AGGR_RSK_RST_T_P2008
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    NOLOGGING
   ,
PARTITION AGGR_RSK_RST_00081120 VALUES LESS THAN (TO_DATE(' 0008-11-20  00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    TABLESPACE RRDB_AGGR_RSK_RST_T_P2008


Last edited by jim mcnamara; 01-31-2012 at 06:42 PM.. Reason: code tags + remove some size tags
 

10 More Discussions You Might Find Interesting

1. Programming

how to find and replace string

hi I wanted to find this char " ^M " in my file and replace it with blank space. I am using Unix system. If i give command " :%s/^M//gc " it wont work so can anyone tell what is command to find and replace thankx (3 Replies)
Discussion started by: mridula
3 Replies

2. UNIX for Dummies Questions & Answers

Find and replace character in a string

Hi all, My problem is the following: I've a script that must list all files in a directory and write this information in a text file. I've tried to get the list through ls command and then write it using msgecho msgecho "`ls $PATH_APS_JOB_ORA`" This works good but the created string... (7 Replies)
Discussion started by: callimaco0082
7 Replies

3. Shell Programming and Scripting

Find the position of a string and replace with another string

Hi, I have a file named "Test_2008_01_21" The file contains a string "manual" that occurs many times in the file How can i find the positions of the string "manual" in the file Ex: if the string " manual " occurs three times in the file. i want to replace the second occurance of string... (6 Replies)
Discussion started by: bab123
6 Replies

4. Shell Programming and Scripting

Inserting a string in another sting

Hi Experts, I need to insert a sting into another string at a specified position. Like the below. Regards, Tin-Tin (3 Replies)
Discussion started by: tinufarid
3 Replies

5. Shell Programming and Scripting

Replace sting in a file

Hi Gurus, I need to search and replace string <! in a file with a blank. Some how my command sed -i 's/\<\!\ is not working .. Kindly help (1 Reply)
Discussion started by: r_t_1601
1 Replies

6. Shell Programming and Scripting

Find and replace string matching criteria

Dear Friends, I am looking for a way to replace a string (multiple lines) starting with something and ending with something (these two values do not change) with blank. Basically I want to delete this code injection accross many sites and folders. Search Code (across files and folders) that... (2 Replies)
Discussion started by: libras
2 Replies

7. Shell Programming and Scripting

find string and replace with string in other file

Dear all, I need your help, I have file like this: file1:23456 01910964830098775635 34567 01942809546554654323 67589 26546854368698023653 09778 58716868568576876878 08675 86178546154065406546 08573 54165843543054354305 . .file2: 23456 25 34567 26 67589 27 (2 Replies)
Discussion started by: attila
2 Replies

8. Shell Programming and Scripting

HPUX find string in directory and filetype and replace string

Hi, Here's my dilemma. I need to replace the string Sept_2012 to Oct_2012 in all *config.py files within the current directory and below directories Is this possible? Also I am trying to find all instances of the string Sept_2012 within files in the current directory and below I have... (13 Replies)
Discussion started by: pure_jax
13 Replies

9. Solaris

How to find and replace a string?

Dear All I need to find and replace a string in a set of files. I try as : #find / -name "*"|xargs grep "Tektra"|grep -v "Tektra GSM BTS" But it doesn't work. It just finds the string in the files. I need to find and replace it.Can you please let me know how to correct it? Thank you (2 Replies)
Discussion started by: hadimotamedi
2 Replies

10. UNIX for Dummies Questions & Answers

Find and Replace string in UNIX

Hi All, Greetings. I have a .dat file which somewhere in its content contains symbol ""^ I want to replace it with "^ I tried with SED command but could not achieve what i wanted sed -e "s/'""^'/'"^'/ig" filename.dat (5 Replies)
Discussion started by: MaddyS
5 Replies
CREATE 
TABLESPACE(7) SQL Commands CREATE TABLESPACE(7) NAME
CREATE TABLESPACE - define a new tablespace SYNOPSIS
CREATE TABLESPACE tablespacename [ OWNER username ] LOCATION 'directory' DESCRIPTION
CREATE TABLESPACE registers a new cluster-wide tablespace. The tablespace name must be distinct from the name of any existing tablespace in the database cluster. A tablespace allows superusers to define an alternative location on the file system where the data files containing database objects (such as tables and indexes) can reside. A user with appropriate privileges can pass tablespacename to CREATE DATABASE, CREATE TABLE, CREATE INDEX or ADD CONSTRAINT to have the data files for these objects stored within the specified tablespace. PARAMETERS
tablespacename The name of a tablespace to be created. The name cannot begin with pg_, as such names are reserved for system tablespaces. username The name of the user who will own the tablespace. If omitted, defaults to the user executing the command. Only superusers can create tablespaces, but they can assign ownership of tablespaces to non-superusers. directory The directory that will be used for the tablespace. The directory must be empty and must be owned by the PostgreSQL system user. The directory must be specified by an absolute path name. NOTES
Tablespaces are only supported on systems that support symbolic links. CREATE TABLESPACE cannot be executed inside a transaction block. EXAMPLES
Create a tablespace dbspace at /data/dbs: CREATE TABLESPACE dbspace LOCATION '/data/dbs'; Create a tablespace indexspace at /data/indexes owned by user genevieve: CREATE TABLESPACE indexspace OWNER genevieve LOCATION '/data/indexes'; COMPATIBILITY
CREATE TABLESPACE is a PostgreSQL extension. SEE ALSO
CREATE DATABASE [create_database(7)], CREATE TABLE [create_table(7)], CREATE INDEX [create_index(7)], DROP TABLESPACE [drop_tablespace(7)], ALTER TABLESPACE [alter_tablespace(7)] SQL - Language Statements 2010-05-14 CREATE TABLESPACE(7)
All times are GMT -4. The time now is 01:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy