Sponsored Content
Top Forums Shell Programming and Scripting sed to remove newline chars based on pattern mis-match Post 302976874 by RudiC on Thursday 7th of July 2016 01:26:17 PM
Old 07-07-2016
Why do you insist on sed and aren't happy with the awk solution?

Try
Code:
sed ':L; /;$/bX; N; bL; :X; s/\n/ /g' file
Table1@Table2@SELECT COL1, COL2,COL3,  COL4,COL5 FROM TABLE1 INNER JOIN TABLE2 ON COL1=COL21 AND COL2=COL22;
Table3@Table4@SELECT COL1, COL2, COL3, COL4,COL5 FROM TABLE1 INNER JOIN TABLE2 ON COL1=COL21 AND COL2=COL22;

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep and sed to find a pattern and add newline

Hello All, I have log file the result from a multithreaded process. So when a process finishes it will write to this log file as 123 rows merged. The issue is sometimes the processess finish at the same time or write to the file at the same time as 123 rows merged.145 rows merged. At... (5 Replies)
Discussion started by: ssikhar
5 Replies

2. Shell Programming and Scripting

sed ksh remove newline between 2 containers

If we assume that each line between the {} container is an XML document then What I want to remove the newline character from all lines within each container to have one XMDL document per line I wrote a bit of sed after trawling the web: e.g. #!/bin/sed -nf H /}/ { x s/\n//g p... (3 Replies)
Discussion started by: JamesJSC
3 Replies

3. Shell Programming and Scripting

SED: how to remove newline after pattern?

Hi, I have the following XML not well-indented code: <hallo >this is a line </hallo> So I need to remove the newline. This syntax finds what I need to correct, but I don't know how to remove the newline after my pattern: sed 's/<.*$/&/' How can I subtract the newline after my... (1 Reply)
Discussion started by: nico.ben
1 Replies

4. Shell Programming and Scripting

remove newline chars in each record of file

Hi, I have a fixed width file with record length 10. I need to remove multiple newline characters present in each record. EX: af\n72/7\n s\n3\nad\n 2\n\n33r\n In the above file I want to remove new lines in red color(\n) but not (\n) Please provide me a solution. Thanks, Sri (1 Reply)
Discussion started by: srilaxmi
1 Replies

5. Shell Programming and Scripting

sed/awk remove newline

Hi, I have input file contains sql queries i need to eliminate newlines from it. when i open it vi text editor and runs :%s/'\n/'/g it provides required result. but when i run sed command from shell prompt it doesn't impact outfile is still same as inputfile. shell] sed -e... (6 Replies)
Discussion started by: mirfan
6 Replies

6. Shell Programming and Scripting

remove newline between two string with sed command in unix shellscript

I have a file (test.dat) which contains data like this 459|199811047|a |b |shan kar|ooty| 460|199811047|a |bv |gur u|cbe| but I need it like: 459|199811047|a |b |shankar|ooty| 460|199811047|a |b |guru|cbe| While reading the data from this file, I don't want to remove newline from the end of... (4 Replies)
Discussion started by: jcrshankar
4 Replies

7. Shell Programming and Scripting

Remove duplicate chars and sort string [SED]

Hi, INPUT: DCBADD OUTPUT: ABCD The SED script should alphabetically sort the chars in the string and remove the duplicate chars. (5 Replies)
Discussion started by: jds93
5 Replies

8. Shell Programming and Scripting

Awk-sed help : to remove first and last line with pattern match:

awk , sed Experts, I want to remove first and last line after pattern match "vg" : I am trying : # sed '1d;$d' works fine , but where the last line is not having vg entry it is deleting one line of data. - So it should check for the pattern vg if present , then it should delete the line ,... (5 Replies)
Discussion started by: rveri
5 Replies

9. UNIX for Dummies Questions & Answers

Mac OS X sed, add newline after pattern

Hi, I've been trying to work out how to add a new line to a file when the pattern matches .dmg. I've been searching Google but yet not found a working solution. Help would be appreciated... (9 Replies)
Discussion started by: pburge
9 Replies

10. Shell Programming and Scripting

sed - print only the chars that match a given set in a string

For a given string that may contain any ASCII chars, i.e. that matches .*, find and print only the chars that are in a given subset. The string could also have numbers, uppercase, special chars such as ~!@#$%^&*(){}\", whatever a user could type in without going esoteric For simplicity take... (1 Reply)
Discussion started by: naderra
1 Replies
DBIx::DBStag::SQLTemplate(3pm)				User Contributed Perl Documentation			    DBIx::DBStag::SQLTemplate(3pm)

NAME
DBIx::DBStag::SQLTemplate - A Template for an SQL query SYNOPSIS
# find template by name $template = $dbh->find_template("mydb-personq"); # execute this template, filling in the 'name' attribute $xml = $dbh->selectall_xml(-template=>$template, -bind=>{name => "fred"}); DESCRIPTION
A template represents a canned query that can be parameterized. Templates are collected in directories (in future it will be possible to store them in files or in the db itself). To tell DBStag where your templates are, you should set: setenv DBSTAG_TEMPLATE_DIRS "$HOME/mytemplates:/data/bioconf/templates" Your templates should end with the suffix .stg, otherwise they will not be picked up You can name templates any way you like, but the standard way is to use 2 or 3 fields SCHEMA-OBJECT or SCHEMA-OBJECT-QUALIFIERS (with underscores used within fields) A template file should contain at minimum some SQL; for example: Example template 1 SELECT studio.*, movie.*, star.* FROM studio NATURAL JOIN movie NATURAL JOIN movie_to_star NATURAL JOIN star WHERE [movie.genre = &genre&] [star.lastname = &lastname&] USE NESTING (set(studio(movie(star)))) Thats all! However, there are ways to make your template more useful Example template 2 :SELECT studio.*, movie.*, star.* :FROM studio NATURAL JOIN movie NATURAL JOIN movie_to_star NATURAL JOIN star :WHERE [movie.genre = &genre&] [star.lastname = &lastname&] :USE NESTING (set(studio(movie(star)))) // schema: movie desc: query for fetching movies By including : at the beginning it makes it easier for parsers to assemble SQL (this is not necessary for DBStag however) After the // you can add tag: value data. You should set schema: if you want the template to be available to users of a db that conforms to that schema GETTING A TEMPLATE The DBIx::DBStag object gives various methods for fetching templates by name, by database or by schema VARIABLES WHERE clause variables in the template look like this &foo& variables are bound at query time my $set = $dbh->selectall_stag(-template=>$t, -bind=>["bar"]); or my $set = $dbh->selectall_stag(-template=>$t, -bind=>{foo=>"bar"}); If the former is chosen, variables are bound from the bind list as they are found OPTIONAL BLOCKS WHERE [ foo = &foo& ] If foo is not bound then the part between the square brackets is left out Multiple option blocks are ANDed together An option block need not contain a variable - if it contains no &variable& name it is automatically ANDed BINDING OPERATORS The operator can be bound at query time too WHERE [ foo => &foo& ] Will become either WHERE foo = ? or WHERE foo LIKE ? or WHERE foo IN (f0, f1, ..., fn) Depending on whether foo contains the % character, or if foo is bound to an ARRAY METHODS
name Usage - $name = $template->name Returns - str Args - every template has a name that (should) uniquely identify it desc Usage - $desc = $template->desc Returns - str Args - templates have optional descriptions get_varnames Usage - $varnames = $template->get_varnames Returns - listref of strs Args - Returns the names of all variable used in this template WEBSITE
<http://stag.sourceforge.net> AUTHOR
Chris Mungall <cjm@fruitfly.org> COPYRIGHT
Copyright (c) 2003 Chris Mungall This module is free software. You may distribute this module under the same terms as perl itself perl v5.12.4 2010-02-01 DBIx::DBStag::SQLTemplate(3pm)
All times are GMT -4. The time now is 01:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy