sed: removing backticks from certain lines


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers sed: removing backticks from certain lines
# 1  
Old 02-27-2008
sed: removing backticks from certain lines

Hi,

I would like to change some lines in my mysql-dump, because there a syntax problems with some version of mysql.

I 'd like to change

USE ´someDatabase´;

to

USE someDatabase;

(without backticks) using the sed command in the shell

Thanks & best regards

Bernd
# 2  
Old 02-27-2008
Code:
sed -e "s/\`//g" file.txt

# 3  
Old 02-27-2008
hi,

you can use the below command if the backticks are used only here (`someDatabase`)

cat input_file1|sed "s/\`//g" >output_file

If the backticks are used in many fileds or columns means use the below command,

cat input_file1|sed "s/\`someDatabase\`/someDatabase/g" >output_file
# 4  
Old 02-27-2008
thanks,

but I do not want to remove all ´ backticks, but only if it is in the folloing line

USE ´database´;

and I do not know the name of the database (which is between the backtick", so I would need a regEx and a reference back for it

so something like:

sed '/^USE ´(RegularExpression)´;/USE \reference;/g' mysql1.sql >mysql2.sql

best regards

Bernd
# 5  
Old 02-27-2008
Quote:
Originally Posted by bjb
thanks,

but I do not want to remove all ´ backticks, but only if it is in the folloing line

USE ´database´;

and I do not know the name of the database (which is between the backtick", so I would need a regEx and a reference back for it

so something like:

sed '/^USE ´(RegularExpression)´;/USE \reference;/g' mysql1.sql >mysql2.sql

best regards

Bernd
Code:
sed -e "s/^USE \`\(.*\)\`/USE \1/g" mysql1.sql

# 6  
Old 02-27-2008
Thank you, works perfect!

Best regards

Bernd
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing lines from a file

I have a file `/tmp/wrk` containing filenames with paths. I want to remove filenames from this file, for example remove all filenames containing alja cagr cavt clta cmdo or corl remove all filenames containing data for days in region `d.2016.001` to `d.2016.207` remove all filenames... (10 Replies)
Discussion started by: kristinu
10 Replies

2. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

GM, I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed. I am assuming that sed, awk or even perl could do what I need. I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies

3. Shell Programming and Scripting

Joining broken lines and removing empty lines

Hi - I have req to join broken lines and remove empty lines but should NOT be in one line. It has to be as is line by line. The challenge here is there is no end of line/start of line char. thanks in advance Source:- 2003-04-34024|04-10-2003|Claims|Claim|01-13-2003|Air Bag:Driver;... (7 Replies)
Discussion started by: Jackceasar123
7 Replies

4. UNIX for Dummies Questions & Answers

Removing PATTERN from txt without removing lines and general text formatting

Hi Everybody! First post! Totally noobie. I'm using the terminal to read a poorly formatted book. The text file contains, in the middle of paragraphs, hyphenation to split words that are supposed to be on multiple pages. It looks ve -- ry much like this. I was hoping to use grep -v " -- "... (5 Replies)
Discussion started by: AxeHandle
5 Replies

5. Shell Programming and Scripting

Removing Multiple lines below a keyword using SED?

I have 9,000 + html files. I am using the following to remove the content from a certain line up for i in `ls` do sed '1,569d' $i > $i.bak done This will remove the unwanted formatting keeping the content I need which changes in each HTML file. the problem I have now is that the... (2 Replies)
Discussion started by: deaconf19
2 Replies

6. Shell Programming and Scripting

Removing last two lines

I have an awk script that replaces ">" with % %> %< SOURCE", ++i %( PHASE 1", i I use the following script />/ { if ( FNR > 1 ) { print "%)" print "%>" } print "" print "%< SOURCE", ++i (11 Replies)
Discussion started by: kristinu
11 Replies

7. Shell Programming and Scripting

Removing empty lines(space) between two lines containing strings

Hi, Please provide shell script to Remove empty lines(space) between two lines containing strings in a file. Input File : A1/EXT "BAP_BSC6/07B/00" 844 090602 1605 RXOCF-465 PDTR11 1 SITE ON BATTERY A2/EXT... (3 Replies)
Discussion started by: sudhakaryadav
3 Replies

8. Shell Programming and Scripting

Removing lines having #

I have a script which goes to different directories and gives the values of all the input parameters, Something as follows cd /opt grep script-filter = yes *.conf grep user-and-group-in-same-suffix = yes *.conf grep worker-threads = 300 *.conf grep failover-auth = *.conf grep... (9 Replies)
Discussion started by: openspark
9 Replies

9. Shell Programming and Scripting

Removing lines with sed

Here is some code output that I have: architecture ppc cputype CPU_TYPE_POWERPC cpusubtype CPU_SUBTYPE_POWERPC_ALL offset 4096 size 184464 align 2^12 (4096) architecture ppc64 cputype CPU_TYPE_POWERPC64 cpusubtype CPU_SUBTYPE_POWERPC_ALL offset 192512 ... (5 Replies)
Discussion started by: pcwiz
5 Replies

10. Shell Programming and Scripting

Backticks within backticks?

Hi, I'm trying to do something like this: range= `expr `date '+%m'` - 1` and it does not work. How can I tell it to evaluate an expression within another expression evaluation? I was at first worried that `date '+%m'` would return a string but apparently expr does the math okay normally, so the... (3 Replies)
Discussion started by: jeriryan87
3 Replies
Login or Register to Ask a Question