[ILUGC] Re: [Help] Copying and Pasting text into multiple files

  • From: Baskar Selvaraj <baskar@xxxxxxxxxxxx>
  • To: ilugc@xxxxxxxxxxxxx
  • Date: Fri, 30 Dec 2016 20:03:31 +0530

On 12/22/16, Baskar Selvaraj <baskar@xxxxxxxxxxxx> wrote:

Dear all,

I have around 3K HTML files which I had to insert <title> tags, provided
the title tags are available in a separate file (see the pastebin)

Titles

http://pastebin.com/ZEKnQEay

The HTML file informations are available in a separate file (both the files
has the same line count and also in order). Now, I have to take the title
information from 'title' file and insert into corresponding HTML file based
on the HTML filename available in the below file.

HTML Filename informations

http://pastebin.com/nh23PRc5

Any SED/AWK solution would be helpful.

--
S. Baskar


Solved. Posting the solution just as a followup.

#!/bin/bash
count=1
while read lineA
     do export titlelist=$lineA
        file=`sed -n "$count"p tedtalks.2261`
        sed -i -e "s/\$ctitle/$(echo $titlelist | sed -e
's/[\/&]/\\&/g')/g" $file
        count=`expr $count + 1`
done < titles.2261

S. Baskar
_____________________________________
ILUGC List: http://www.freelists.org/list/ilugc
ILUGC Web: http://ilugc.in/

Other related posts: