Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to remove a char before a pattern? Post 302991992 by raju2016 on Monday 20th of February 2017 12:27:16 PM
Old 02-20-2017
How to remove a char before a pattern?

Hi I have a file where i want to remove a char before a specific pattern.
exp:
Code:
CREATE TABLE
 (
 A,
 B,
 C,      ----comma needs to be removed
 )AS SELECT
 A,
 B,
 C,      ----comma needs to be removed
 FROM  TABLE.

So i want to delete the comma(,) after the C both ways.Pattern can be look for ")AS SELECT" and "FROM" .So before this pattern i want to delete a single char which is comma.
my output should:

Code:
CREATE TABLE
 (
 A,
 B,
 C      -----removed comma
 )AS SELECT
 A,
 B,
 C      -----removed comma
 FROM  TABLE.


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 02-20-2017 at 02:48 PM.. Reason: Added/Changed CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove new line char from a string

Hi Can anyone tell me how can i remove new line character from a string. My requirement is to read a line from a file and store it to a string. read line string1=$line read line string2=$line echo $string1$string2 The result i am getting in different line. i want the output in the same... (1 Reply)
Discussion started by: sreedivia
1 Replies

2. Shell Programming and Scripting

Help needed to remove a char from a specified sub-string

Hi! I'm having trouble usind sed to remove the char ' from within a database's varchar register's sql. For example, on the following sql: INSERT INTO patrimonio_municipal.patrimonio_municipal_airc_tmp Values('|Estação Elevatória|',|16723|,'|Grandes Reparações|', '|2010-03-26... (3 Replies)
Discussion started by: cremat0rio
3 Replies

3. Shell Programming and Scripting

can I remove the first char using AWK?

Hi everyone, suppose that I have the following line: #test your knowledge can I use AWK to print the word "test" only? without the #? what should I change to this: awk '{print $1}' thanks in advance guys (2 Replies)
Discussion started by: Abdulelah
2 Replies

4. Shell Programming and Scripting

Remove char after Colon

Hi guys, This is my input 2735:<7001> 34 789 701 2 2774:<7001> 34 789 701 2 How to delete characters after colon : Including colon : too ? My output should... (3 Replies)
Discussion started by: gowrishankar05
3 Replies

5. UNIX Desktop Questions & Answers

Help me to remove junk char

I wanted to remove junk char in my csv. :mad: Input file format: "17","9986782190","0","D","2" "17","9900918331","0","D","2" "13","9986782194","0","A","2" Output file format 9986782190 9900918331 9986782194 And one more thing all the time "13"," this will be different Ex: . (2 Replies)
Discussion started by: Siddartha
2 Replies

6. Red Hat

How to remove a special char using sed

consider this is my sample file format. in this i want to remove ^@ with space . please help me in this problm 7305,1310184890,0,0,12,201370,FCASTBHBR0 ,XX ,2,1,2,0,^@,1,1,0,3,1303862400,0,1577923199,1,10,FCASTOR SEED EX-BHABHAR ... (2 Replies)
Discussion started by: ponmuthu-lnx
2 Replies

7. Shell Programming and Scripting

How to remove the # char form a line?

Hi, my file has below details and I want remove the # char from only specific line. #TEST:00:START #TEST1:01:INPROCESS #TEST2:02:ABOUTTO #TEST3:03:COMP i.e if want remove the # from 2nd line then file to be updated as #TEST:00:START TEST1:01:INPROCESS #TEST2:02:ABOUTTO... (6 Replies)
Discussion started by: sandyrajh
6 Replies

8. Shell Programming and Scripting

To get char between pattern

hi, this my text ...................... Read 21 physical / 21 logical HMMs Read lattice with 16 nodes / 36 arcs Created network with 53 nodes / 73 links File: speech.mfc !sil two eight six nine six eight !sil == -68.5133 (Act=50.4)...................... i need to extract output text... (4 Replies)
Discussion started by: sreejithalokkan
4 Replies

9. UNIX for Dummies Questions & Answers

Remove newline char from variable

I have a file ABC.DAT with 2 columns avaialble Data format : XYZ!$#$!120 XXZ!$#$!1000 YYZ!$#$!104 While running the following code : FILE_COUNTER=1; RECORD_CN_FILE_COUNT=$((`wc -l ABC.DAT| cut -f1 -d' '`)); while do FILE_NAME=`cat ABC.DAT.DAT| head -$FILE_COUNTER |tail -1 | awk -F... (1 Reply)
Discussion started by: Nikhil Gautam
1 Replies

10. UNIX for Dummies Questions & Answers

Remove char if not a number

I need to write a BASH script that takes a 2 character string and removes the second character if it is not a digit e.g. If the string is numberical value >9 e.g. string1 = '34' then leave string1 = '34'. However if the string is <10 e.g. string1 = '3X' then remove the second char (which... (7 Replies)
Discussion started by: millsy5
7 Replies
CREATE FOREIGN 
TABLE(7) PostgreSQL 9.2.7 Documentation CREATE FOREIGN TABLE(7) NAME
CREATE_FOREIGN_TABLE - define a new foreign table SYNOPSIS
CREATE FOREIGN TABLE [ IF NOT EXISTS ] table_name ( [ { column_name data_type [ OPTIONS ( option 'value' [, ... ] ) ] [ NULL | NOT NULL ] } [, ... ] ] ) SERVER server_name [ OPTIONS ( option 'value' [, ... ] ) ] DESCRIPTION
CREATE FOREIGN TABLE will create a new foreign table in the current database. The table will be owned by the user issuing the command. If a schema name is given (for example, CREATE FOREIGN TABLE myschema.mytable ...) then the table is created in the specified schema. Otherwise it is created in the current schema. The name of the foreign table must be distinct from the name of any other foreign table, table, sequence, index, or view in the same schema. CREATE FOREIGN TABLE also automatically creates a data type that represents the composite type corresponding to one row of the foreign table. Therefore, foreign tables cannot have the same name as any existing data type in the same schema. To be able to create a table, you must have USAGE privilege on all column types. PARAMETERS
IF NOT EXISTS Do not throw an error if a relation with the same name already exists. A notice is issued in this case. Note that there is no guarantee that the existing relation is anything like the one that would have been created. table_name The name (optionally schema-qualified) of the table to be created. column_name The name of a column to be created in the new table. data_type The data type of the column. This can include array specifiers. For more information on the data types supported by PostgreSQL, refer to Chapter 8, Data Types, in the documentation. NOT NULL The column is not allowed to contain null values. NULL The column is allowed to contain null values. This is the default. This clause is only provided for compatibility with non-standard SQL databases. Its use is discouraged in new applications. server_name The name of an existing server for the foreign table. OPTIONS ( option 'value' [, ...] ) Options to be associated with the new foreign table or one of its columns. The allowed option names and values are specific to each foreign data wrapper and are validated using the foreign-data wrapper's validator function. Duplicate option names are not allowed (although it's OK for a table option and a column option to have the same name). EXAMPLES
Create foreign table films with film_server: CREATE FOREIGN TABLE films ( code char(5) NOT NULL, title varchar(40) NOT NULL, did integer NOT NULL, date_prod date, kind varchar(10), len interval hour to minute ) SERVER film_server; COMPATIBILITY
The CREATE FOREIGN TABLE command largely conforms to the SQL standard; however, much as with CREATE TABLE, NULL constraints and zero-column foreign tables are permitted. SEE ALSO
ALTER FOREIGN TABLE (ALTER_FOREIGN_TABLE(7)), DROP FOREIGN TABLE (DROP_FOREIGN_TABLE(7)), CREATE TABLE (CREATE_TABLE(7)), CREATE SERVER (CREATE_SERVER(7)) PostgreSQL 9.2.7 2014-02-17 CREATE FOREIGN TABLE(7)
All times are GMT -4. The time now is 03:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy