Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8311225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:44:26+00:00 2026-06-08T19:44:26+00:00

I need change price the HTML file, which search and store them in array

  • 0

I need change price the HTML file, which search and store them in array but I have to change and save /nuevo-focus.html

price=( `cat /home/delkav/info-sitioweb/html/productos/autos/nuevo-focus.html | grep -oiE '([$][0-9.]{1,7})'|tr '\n' ' '` )

 price2=( $90.880 $0 $920 $925 $930 $910 $800 $712 $27.220 $962 )
 sub (){
 for item in "${price[@]}"; do
    for x in ${price2[@]}; do
      sed s/$item/$x/g > /home/delkav/info-sitioweb/html/productos/autos/nuevo-focus.html
     done
 done
 }

 sub

Output the “cat /home/…/nuevo-focus.html|grep -oiE ‘([$][0-9.]{1,7})’|tr ‘\n’ ‘ ‘` )” is…

$86.880 $0 $912 $908 $902 $897 $882 $812 $25.725 $715
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:44:27+00:00Added an answer on June 8, 2026 at 7:44 pm

    In bash the variables $0 through $9 refer to the respective command line arguments of the script being run. In the line:

    price2=( $90.880 $0 $920 $925 $930 $910 $800 $712 $27.220 $962 )
    

    They will be expanded to either empty strings or the command line arguments that you gave the script.

    Try doing this instead:

    price2=( '$90.880' '$0' '$920' '$925' '$930' '$910' '$800' '$712' '$27.220' '$962' )
    

    EDIT for part two of question

    If what you are trying to do with the sed line is replace the prices in the file, overwriting the old ones, then you should do this:

    sed -i  s/$item/$x/g /home/delkav/info-sitioweb/html/productos/autos/nuevo-focus.html
    

    This will perform the substitution in place (-i), modifying the input file.


    EDIT for part three of the question

    I just realized that your nested loop does not really make sense. I am assuming that what you want to do is replace each price from price with the corresponding price in price2

    If that is the case, then you should use a single loop, looping over the indices of the array:

    for i in ${!price[*]}
    do
        sed -i  "s/${price[$i]}/${price2[$i]}/g" /home/delkav/info-sitioweb/html/productos/autos/nuevo-focus.html
    done
    

    I’m not able to test that right now, but I think it should accomplish what you want.

    To explain it a bit:

    ${!price[*]} gives you all of the indices of your array (e.g. 0 1 2 3 4 ...)

    For each index we then replace the corresponding old price with the new one. There is no need for a nested loop as you have done. When you execute that, what you are Basically doing is this:

    replace every occurence of "foo" with "bar"
    # at this point, there are now no more occurences of "foo" in your file
    # so all of the other replacements do nothing
    replace every occurence of "foo" with "baz"
    replace every occurence of "foo" with "spam"
    replace every occurence of "foo" with "eggs"
    replace every occurence of "foo" with "qux"
    replace every occurence of "foo" with "whatever"
    etc...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this situation: $(#button).toggle(function(){ $(#window).animate({top:'0%'},1000); },function(){ $(#window).animate({top:'-100%'},1000); }); but I need change it
Ok so I have a text file that will change regularly that I need
I need change background of all text that have two spaces from the start
I have database, and in one the tables I need change the values of
I need to change table name from lowercase to uppercase but using this statement
I have a working query that retrieves the data that I need, but unfortunately
Problem: Items have optional price. If the price is 0 (or I can change
I need to access to the data of a html cell,but before that ,I
I have an application where I need to store historical prices for a product
One of my project need a function to detect the price change of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.