LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-20-2017, 03:08 PM   #1
rfvelasco
LQ Newbie
 
Registered: Feb 2017
Posts: 2

Rep: Reputation: Disabled
Need to add double and single quotes in SED


Input

db2 RUNSTATS ON TABLE ITMUSER.AMC_Internet_Service_Element_Y WITH DISTRIBUTION AND DETAILED INDEXES ALL SHRLEVEL CHANGE;

Desired output

db2 'RUNSTATS ON TABLE "ITMUSER"."AMC_Internet_Service_Element_Y" WITH DISTRIBUTION AND DETAILED INDEXES ALL SHRLEVEL CHANGE';

Requirements:

Add a single quote before RUNSTATS, add double quotes around ITMUSER and AMC_Internet_Service_Element_Y and a final single quote after CHANGE
 
Old 02-20-2017, 03:11 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Sounds like a homework question. What have you done and where are you stuck?
 
Old 02-20-2017, 03:41 PM   #3
rfvelasco
LQ Newbie
 
Registered: Feb 2017
Posts: 2

Original Poster
Rep: Reputation: Disabled
I'm stuck getting the single and double quotes around the correct literals. I just thought I would post to see if a SED guru would know the answer quicker than me.
 
Old 02-20-2017, 03:54 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
The quote characters aren't special to sed. You just need to get them past the shell. You can set the "-x" option in your shell ("set -x") and see how the arguments are getting passed to sed. (Use "set +x" to turn that back off.)
 
Old 02-20-2017, 10:06 PM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,864
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Shell variables might make it cleaer:
Code:
From="from"; To="'to'"; sed "s;$From;$To;"
From="from"; To="\"to\""; sed "s;$From;$To;"
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Lost with single and double quotes with bash! Fnux Ubuntu 2 03-31-2013 11:38 PM
Parse with sed to add double quotes marksa Programming 4 02-24-2013 05:04 PM
translate value from single quotes to double quotes venkateshrupineni Linux - Newbie 2 06-14-2012 03:03 PM
[SOLVED] how do i add a line with double quotes in sed? Beandip408 Linux - Newbie 1 02-01-2012 03:22 PM
Using single quotes vs double quotes in PHP strings vharishankar Programming 6 07-11-2005 11:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration