bash - Copy/publish images linked from the html files to another server and update the HTML files referencing them -


i publishing content drupal cms static html pages on domain, hosted on second server. building html files simple (using php/mysql write files).

i have list of images referenced in html, of exist below /userfiles/ directory.

cat *.html | grep -oe [^\'\"]+userfiles[\/.*]*/[^\'\"] | sort | uniq 

which produces list of files

http://my.server.com/userfiles/another%20user1.jpg http://my.server.com/userfiles/image/image%201.jpg ... 

my next step copy these images across second server , translate tags in html files.


i understand sed tool need. e.g.:

sed 's/[^"]\+userfiles[\/image]\?\/\([^"]\+\)/\/images\/\1/g' 

should change http://my.server.com/userfiles/another%20user1.jpg /images/another%20user1.jpg, cannot work out how use script. i.e. can use update files in place or need juggle temporary files, etc. how can ensure files moved correct location on second server

it's possible use sed change file in-place using -i option.

for use it's if it's easier/better create new file changes old, copy 2nd domain using scp (or similar). or may easier copy file first, modify once it's on remote server (less management of new filenames way).


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -