LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-13-2010, 01:23 PM   #1
gqchynaboy
LQ Newbie
 
Registered: Jul 2003
Posts: 20

Rep: Reputation: 0
Help with the sed command


What I'm trying to accomplish is

0) Ask the user for a URL ex. http://thisIsATest/homepage/blah.html and grab it's contents and store it.
1) Take that URL and strip off anything for the last '/'
2) Then append 'images/' to the end of the URL
3) And finally use the sed command to search for any image paths ex. images/spacer.gif and replace it with the URL in step #2

Currently I'm stuck at Step3 and can't get it to do the search and replace correctly. It either inserts it as ${S} or I error out with bad flag in substitute command: '/'


Code:
#!/bin/bash

USERADOBE='someUser'
PWADOBE='somePass'

echo ""
read -p "Enter/Paste the URL >> " myURL

cd $HOME/Desktop

curl "${myURL}" -u "${USERADOBE}":"${PWADOBE}" > editedHTML.html

t=${myURL%*/*}
echo "$t"
s="${t}""/images/"
echo "$s"


 #sed -e 's/images\/'/${s}'/' >> editedHTML.html
 sed -e 's/images\//'"${s}"'/' editedHTML.html >> blah.html
 
Old 01-13-2010, 01:29 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
How about:
Code:
sed "s/images\//$s/"
OR
Code:
sed "s%images/%$s%"
 
Old 01-13-2010, 01:58 PM   #3
gqchynaboy
LQ Newbie
 
Registered: Jul 2003
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pixellany View Post
How about:
Code:
sed "s/images\//$s/"
OR
Code:
sed "s%images/%$s%"
Thanks I got it to work using your 2nd example. =]
 
  


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
need help with sed command cbtsig Linux - Newbie 10 04-16-2009 08:52 PM
sed command help tekmann33 Linux - Newbie 1 10-20-2008 05:06 PM
sed command shyamdey Programming 2 08-30-2006 12:06 AM
sed command Kalyani1 Linux - Software 28 12-07-2005 12:48 PM
sed command linuxdev Linux - Newbie 9 02-24-2004 05:50 PM


All times are GMT -5. The time now is 04:08 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration