Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Curious

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 07-27-2011   -   Original Discussion by GQiang
GQiang's Unix or Linux Image
GQiang GQiang is offline
Registered User
 
Join Date: Jul 2011
Last Activity: 21 July 2012, 1:00 AM EDT
Posts: 30
Thanks: 9
Thanked 0 Times in 0 Posts
Curious

I dont get something about sed

If i have a text file inside contain

Code:
a:a:a:a:a



Code:
sed "s/"$title:$author:$price:$qtyAvailable:$qtySold"/"$Ntitle:$author:$price:$qtyAvailable:$qtySold"/"

This work!!

but

If i have a text file inside contain

Code:
Tom Tom:La La:Di Di :Do Do :De DE

It cannot work =(
error


Code:
sed: -e expression #1, char 7: unterminated `s' command


Last edited by pludi; 07-27-2011 at 10:16 AM..
Sponsored Links
    #2  
Old Unix and Linux 07-27-2011   -   Original Discussion by GQiang
Neo's Unix or Linux Image
Neo Neo is offline Forum Staff  
Administrator
 
Join Date: Sep 2000
Last Activity: 17 January 2018, 10:26 AM EST
Location: Asia pacific region
Posts: 14,292
Thanks: 960
Thanked 1,317 Times in 628 Posts
Hello,

Per our forum rules, all threads must have a descriptive subject text. For example, do not post questions with subjects like "Help Me!", "Urgent!!" or "Doubt". Post subjects like "Execution Problems with Cron" or "Help with Backup Shell Script".

The reason for this is that nearly 95% of all visitors to this site come here because they are referred by a search engine. In order for future searches on your post (with answers) to work well, the subject field must be something useful and related to the problem!

In addition, current forum users who are kind enough to answer questions should be able to understand the essence of your query at first glance.

So, as a benefit and courtesy to current and future knowledge seekers, please be careful with your subject text. You might receive a forum infraction if you don't pay attention to this.

Thank you.

The UNIX and Linux Forums
Sponsored Links
    #3  
Old Unix and Linux 07-28-2011   -   Original Discussion by GQiang
Chubler_XL's Unix or Linux Image
Chubler_XL Chubler_XL is offline Forum Staff  
Moderator
 
Join Date: Oct 2010
Last Activity: 16 January 2018, 7:20 PM EST
Posts: 3,431
Thanks: 149
Thanked 1,216 Times in 1,115 Posts
The spaces within your variables are being interpreted as additional parameters. Use 1 set of quotes around the whole s/// expression:



Code:
sed "s/$title:$author:$price:$qtyAvailable:$qtySold/$Ntitle:$author:$price:$qtyAvailable:$qtySold/"

Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Curious about the -9 pflickner UNIX for Dummies Questions & Answers 3 11-17-2010 01:48 AM
curious kurosaki Shell Programming and Scripting 6 09-29-2008 10:54 AM
Curious? River Freight Linux 1 10-07-2007 04:40 PM
Curious Dummy highway39 UNIX for Dummies Questions & Answers 1 08-31-2006 08:22 PM
Curious skotapal UNIX for Dummies Questions & Answers 2 02-28-2003 04:33 PM



All times are GMT -4. The time now is 04:15 PM.