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 7172699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:40:08+00:00 2026-05-28T15:40:08+00:00

Supposedly I have this line in my text file which has the following format.

  • 0

Supposedly I have this line in my text file which has the following format.

"Title:Author:Price:QtyAvailable:QtySold"

The contents of my text file is shown below

 Hello World:Andreas:10.50:10:5
 Lord Of The Rings:Duke:50.15:50:20
    (some other records...)

1) User inputs Author and Title.

2) If Program locates the Author+Title, it asks user to Update any of the fields available ( for this case Title, Author, Price etc..

3) For example I will like to update the Price of Hello World book.

4) What can I do to tell the program to extract the contents of the Hello World line, and get into 10.50 to replace the price of the book? (assumes new price of the book will be decided by the user’s input)

Hope to get my answer.
Thanks in advance to those who helped!

  • 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-05-28T15:40:09+00:00Added an answer on May 28, 2026 at 3:40 pm

    Following is a something to get you started:

    Sample Script:

    [jaypal:~/Temp] cat s.sh 
    #!/bin/bash
    
    echo "Author?"
    read author
    
    echo "Title?"
    read title
    
    grep -c "$title:$author" file > /dev/null # Look for a line with matching values
    
    if [ $? == 0 ]; then # If found then offer to change price
        echo "I found the book, Do you want to update price to what?"
        read newprice
        sed -i "s/\($book:$author\):[^:]*:/\1:$newprice:/" file
    fi
    

    Input Data:

    [jaypal:~/Temp] cat file
    Hello World:Andreas:10.50:10:5
    Lord Of The Rings:Duke:50.15:50:20
    

    Execution:

    [jaypal:~/Temp] ./s.sh 
    Author? 
    Andreas
    Title? 
    Hello World
    I found the book, Do you want to update price to what?
    40
    [jaypal:~/Temp] cat file
    Hello World:Andreas:40:10:5
    Lord Of The Rings:Duke:50.15:50:20
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function which is supposed to set a certain time format to
I have a Java program which generates a text file on a UNIX server.
hi guys I have the following file format in hex were as each letter
Ok so basically I have this text file with numbers and letters that's supposed
I have this code, which is supposed to attach a HTML file to the
Supposed I have the following string: string str = <tag>text</tag>; And I would like
Let's say I have this line somewhere in my code: <ul id=mobileBtnsBot> <li> <a
I have a data set in the following format: snp,T2DG0200001,T2DG0200002,T2DG0200003,T2DG0200004 3_60162,AA,AA,AA,AA 3_61495,AA,AA,GA,GA 3_61466,GG,GG,CG,CG The
I have this error again: Notice: Undefined index: IDNUMBER in E:\wamp\www\PHP\create.php on line 5
I have a text file that contains two lines of numbers, all I want

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.