Hi I need to help on finding the below pattern using sed
<b><a href="/home/document.do?assetkey=x-y-abcde-1&searchclause=photo">
and replace as below in the same line on the index file.
<b><a href="/abcde.html">
thx in advance.
Mari
Hi I need to help on finding the below pattern using sed
<b><a href="/home/document.do?assetkey=x-y-abcde-1&searchclause=photo">
and replace as below in the same line on the index file.
<b><a href="/abcde.html">
thx in advance.
Mari
sed 's!<b><a href="/home/document.do?assetkey=x-y-abcde-1&searchclause=photo">!<b><a href="/abcde.html">!' input_file.txt
Thanks for the reply,
But, my input_file.txt will have multiple lines like
<b><a href="/home/document.do?assetkey=x-y-abcde-1&searchclause=photo">
<b><a href="/home/document.do?assetkey=x-y-12345-1&searchclause=photo">
<b><a href="/home/document.do?assetkey=x-y-xvyab-1&searchclause=photo">
<b><a href="/home/document.do?assetkey=x-y-56789-1&searchclause=river">
<b><a href="/home/document.do?assetkey=x-y-12345-1&searchclause=river">
after processing the each line from the input_file.txt, I need the ouput files like
abcde.html
12345.html
xvyab.html
56789.html
12345.html
Need furtehr help on this.
thx & rds,
Mari
cut -d "=" -f3 input_file.txt |cut -d "-" -f3|sed '/^$/d'|sed -e 's/$/\.html/'
awk '/assetkey=x-y/ { gsub(/.*assetkey=x-y-/,"")
gsub(/-1&searchclause.*/,"")
print $0".html"
} ' "file"
or
awk 'BEGIN{FS="-"}
/assetkey=x-y/{
print $3".html"
}' "file"
input:
<b><a href="/home/document.do?assetkey=x-y-abcde-1&searchclause=photo">
<b><a href="/home/document.do?assetkey=x-y-12345-1&searchclause=photo">
<b><a href="/home/document.do?assetkey=x-y-xvyab-1&searchclause=photo">
<b><a href="/home/document.do?assetkey=x-y-56789-1&searchclause=river">
<b><a href="/home/document.do?assetkey=x-y-12345-1&searchclause=river">
output:
<b><a href="/abcde.html">
<b><a href="/12345.html">
<b><a href="/xvyab.html">
<b><a href="/56789.html">
<b><a href="/12345.html">
code:
cat a | sed '/^$/d' > c
cat c | awk 'BEGIN{FS="-"}
{
printf("%s%s%s\n","<b><a href=\"/",$3,".html\">")
}'
rm c