Substitute keyword in html address


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Substitute keyword in html address
# 1  
Old 05-08-2015
Substitute keyword in html address

I have data that looks like the below:

Code:
PXL-A0000005 DTE3504500000005
PXL-A0000007 DTE3504500000007
PXL-A0000014 DTE3504500000014
PXL-A0000015 DTE3504500000015
PXL-A0000016 DTE3504500000016

What I am trying to do is use the value in $1 and substitute it in catno=....&storage . I do not know how to do this, maybe sed ? Thank you Smilie.

Code:
https://www.xxxx.com/add_2_cart.php?catno=PXL-A0236938&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube

Example:
Code:
https://www.xxxx.com/add_2_cart.php?catno=PXL-A0000005&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube

https://www.xxxx.com/add_2_cart.php?catno=PXL-A0000007&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube

https://www.xxxx.com/add_2_cart.php?catno=PXL-A0000014&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube

# 2  
Old 05-08-2015
Code:
while read A B
do
        echo "https://www.xxxx.com/add_2_cart.php?catno=${A}&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube"
done < inputfile

# 3  
Old 05-09-2015
In order to print out the two fields and the web address:

Code:
while read A B
do
        echo "https://www.xxxx.com/add_2_cart.php?catno=${A}&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube"
done < inputfile > "\t" $1, $2, $3 in output.txt


Desired output.txt:
Code:
PXL-A0000005 DTE3504500000005 web address
PXL-A0000007 DTE3504500000007 web address

Edit: using the below my output.txt looks like:

using awk
Code:
  awk '1;getline <"PXLlink.txt"' new.txt > newfile.txt

using bash
Code:
while IFS= read -r lineA && IFS= read -r lineB <&3 ; do echo "$lineA"; echo "$lineB"; done <new.txt 3<PXLlink.txt > file3.txt

Code:
PXL-A0000005 DTE3504500000005 
web address
PXL-A0000007 DTE3504500000007 
web address


Last edited by cmccabe; 05-09-2015 at 01:02 PM.. Reason: added awk and bash code
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk to extract value after keyword in html

Using awk to extract value after a keyword in an html, and store in ts. The awk does execute but ts is empty. I use the tag as a delimiter and the keyword as a pattern, but there probably is a better way. Thank you :). file <html><head><title>xxxxxx xxxxx</title><style type="text/css"> ... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Shell Programming and Scripting

Substitute first occurrence of keyword if occurrence between two other keywords

Assume a string that contains one or multiple occurrences of three different keywords (abbreviated as "kw"). I would like to replace kw2 with some other string, say "qux". Specifically, I would like to replace that occurrence of kw2 that is the first one that is preceded by kw1 somewhere in the... (4 Replies)
Discussion started by: M Gruenstaeudl
4 Replies

3. UNIX for Advanced & Expert Users

C program to detect duplicate ip address if any after assigning ip address to ethernet interface

Hi , Could someone let me know how to detect duplicate ip address after assigning ip address to ethernet interface using c program (3 Replies)
Discussion started by: Gopi Krishna P
3 Replies

4. Shell Programming and Scripting

Search for a Keyword in file and replace another keyword or add at the end of line

Hi I want to implement something like this: if( keyword1 exists) then check if(keyword2 exists in the same line) then replace keyword 2 with New_Keyword else Add New_Keyword at the end of line end if eg: Check for Keyword JUNGLE and add/replace... (7 Replies)
Discussion started by: dashing201
7 Replies

5. UNIX for Advanced & Expert Users

Mutt for html body and multiple html & pdf attachments

Hi all: Been racking my brain on this for the last couple of days and what has been most frustrating is that this is the last piece I need to complete a project. There are numerous posts discussing mutt in this forum and others but I have been unable to find similar issues. Running with... (1 Reply)
Discussion started by: raggmopp
1 Replies

6. Shell Programming and Scripting

Removing all except couple of html tags from html file

I tried to find elegant (or at least simple) way to remove all but couple of html tags from html file, but all examples I found dealt with removing all the tags. The logic of the script would be: - if there is <li> or <ul> on the line, do nothing (=write same line to output) - if there is:... (0 Replies)
Discussion started by: juubuntu
0 Replies

7. Red Hat

Send HTML body and HTML attachment using MUTT command

Hi there.. I need a proper "mutt" command to send a mail with html body and html attachment at a time. Also if possible let me know the other commands to do this task. Please help me.. (2 Replies)
Discussion started by: vickramshetty
2 Replies

8. UNIX for Advanced & Expert Users

shellinabox/html help to insert a keypress with an html button

I am trying to use shellinabox as a terminal emulator. Everything is working except there seems to be no way to simulate an F14 button press in shellinabox. I am already embedding shellinabox in an html page so Im am wondering if there is a way to make an html/js button that will pass F14 to the... (0 Replies)
Discussion started by: syadnom
0 Replies

9. Shell Programming and Scripting

Match keyword on string and substitute under vi

Hi guys, with sed when I need to make a substitution inside a line containing a specific keyword, I usually use: sed '/keyword/ s/cat/dog/g' This will substitute "cat" with "dog" on those lines containing "keyword". Now I want to use this inside vi, for several reason that I cannot... (2 Replies)
Discussion started by: lycaon
2 Replies

10. UNIX for Dummies Questions & Answers

How do I extract text only from html file without HTML tag

I have a html file called myfile. If I simply put "cat myfile.html" in UNIX, it shows all the html tags like <a href=r/26><img src="http://www>. But I want to extract only text part. Same problem happens in "type" command in MS-DOS. I know you can do it by opening it in Internet Explorer,... (4 Replies)
Discussion started by: los111
4 Replies
Login or Register to Ask a Question