LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-23-2015, 12:31 AM   #1
denywinarto
LQ Newbie
 
Registered: Jun 2015
Posts: 1

Rep: Reputation: Disabled
ubuntu, cant expand variable inside sed


Hi,i cant seem to expand a variable (LINKNAME) inside sed... ive used double quotes, changed the delimiter, but i still cant get it to work
Code:
LINKNAME=$(echo -e "${NEW_MOVIES_DIRLIST}" | sed -r 's,FOLTERS_TO_BE_SCANNED/HDD-EXTENDED.-SD./,,g')

NEW_MOVIES_DIRLIST=$(echo -e "${NEW_MOVIES_DIRLIST}" | sed "s,$,LINKNAME,g")
It wont expand LINKNAME, any idea why?

thanks before
 
Old 06-23-2015, 05:28 PM   #2
Ranamon
Member
 
Registered: Feb 2013
Location: Land of Hopenchange
Distribution: Slackware
Posts: 45

Rep: Reputation: Disabled
Quote:
Originally Posted by denywinarto View Post
Hi,i cant seem to expand a variable (LINKNAME) inside sed... ive used double quotes, changed the delimiter, but i still cant get it to work
Code:
LINKNAME=$(echo -e "${NEW_MOVIES_DIRLIST}" | sed -r 's,FOLTERS_TO_BE_SCANNED/HDD-EXTENDED.-SD./,,g')

NEW_MOVIES_DIRLIST=$(echo -e "${NEW_MOVIES_DIRLIST}" | sed "s,$,LINKNAME,g")
It wont expand LINKNAME, any idea why?

thanks before
You have a typo in there: "s,$,LINKNAME,g"

It needs to be: "s,$LINKNAME,<what hoes here>,g"

The dollar sign needs to go right in front of the variable name. What you have up there literally says to find a string that consists of $ and substitute LINKNAME for it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Calculation using variable inside variable unclesamcrazy Linux - Newbie 7 04-21-2015 10:24 AM
[bash] re-evaluate variable inside variable muzzol Programming 9 12-01-2010 12:31 PM
[Bash] How to expand path variable that contains spaces and wildcards jkv Programming 11 02-17-2010 01:19 AM
How to make shell variable don't expand immediately linuxgentoo Programming 1 06-13-2009 09:36 AM
Sed search for variable and delete entire line, but variable contains forward /'s Passions Programming 2 11-10-2008 04:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:53 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