Need help for script.

Hi

I want to extract the trans_id only from the following url :

<a href="https://www.stage2qa079.paypal.com/cgi-bin/webscr?cmd=\_ebay-checkout&session\_id=0&business=GY8Q3EQNoTkzyenam5jQ0WoupxDvrymDJySVd1NgY1ZqgJ17t9IqlQk%2FxxJAOTpH%2F95j9132N05ThOWSMGAduw%3D%3D&sc\_track=0&loc\_id=1&linkstate=hard&shipping\_costs\_calculable=true&psite\_id=0&xinfo=JrdYd3Gy8SLTgMermJrC0Cxo0nXWS2lG6m5tF5lcpzrErrQNipeEZ0w5WguOeEaR03JfT0UA%2BXouyk6%2BXA%2B9EA%3D%3D&site\_id=us&iscouponchosen=false&trans\_id=7166101006&item_id=160000833964" alt="Go to PayPal Checkout">https://www.stage2qa079.paypal.com/cgi-bin/webscr?cmd=\_ebay-checkout&session\_id=0&business=GY8Q3EQNoTkzyenam5jQ0WoupxDvrymDJySVd1NgY1ZqgJ17t9IqlQk%2FxxJAOTpH%2F95j9132N05ThOWSMGAduw%3D%3D&sc\_track=0&loc\_id=1&linkstate=hard&shipping\_costs\_calculable=true&psite\_id=0&xinfo=JrdYd3Gy8SLTgMermJrC0Cxo0nXWS2lG6m5tF5lcpzrErrQNipeEZ0w5WguOeEaR03JfT0UA%2BXouyk6%2BXA%2B9EA%3D%3D&site\_id=us&iscouponchosen=false&trans\_id=7166101006&item_id=160000833964&lt;/a&gt;
Pls give the script.

Thanks a lot -
Jeyendran Kathirvel

i think something like ` echo $string | sed s/.*trans_id=//g |cut -f 1 -d "&" `
would do.
it replaces first everything including and ending with trans_id= to "" and then it choses the first field with as a field seperator &.
soemthing like this would do i think :stuck_out_tongue:

echo '
> <a href="https://www.stage2qa079.paypal.com/cgi-bin/webscr?cmd=\_ebay-checkout&session_id=0&business=GY8Q3EQNoTkzyenam5jQ0WoupxDvrymDJySVd1NgY1ZqgJ17t9IqlQk%2FxxJAOTpH%2F 95j9132N05ThOWSMGAduw%3D%3D&sc_track=0&loc_id=1&linkstate=hard&shipping_costs_calculable=true&psite_ id=0&xinfo=JrdYd3Gy8SLTgMermJrC0Cxo0nXWS2lG6m5tF5lcpzrErrQNipeEZ0w5WguOeEaR03JfT0UA%2BXouyk6%2BXA%2B 9EA%3D%3D&site_id=us&iscouponchosen=false&trans_id=7166101006&item_id=160000833964" alt="Go to PayPal Checkout">https://www.stage2qa079.paypal.com/c...nchosen=false&trans\_id=7166101006&item_id=160000833964&lt;/a&gt;' | sed s/.*trans_id=//g |cut -f 1 -d "&"

7166101006

All in one:

sed 's/.*trans_id=\(.*\)&item_id.*/\1/g' infile