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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:34:08+00:00 2026-05-22T14:34:08+00:00

How do I isolate quoted text from a file to a shell variable? Also:

  • 0

How do I isolate quoted text from a file to a shell variable?
Also: how do I ignore lines starting with '#'?

Let’s say I have the text file

8723 "full name" "more data here"
#5002 "another name" "bla bla bla"
7129 "single" blablabla
3910 noquote "bla bla bla"

and I want to write a script that executes

#!/bin/sh
myscript <KEY> "<FULL NAME>" "<MORE DATA>"

for each line in the text file.
If it makes it easier, you can assume FULLNAME and MOREDATA in the text file are always enclosed in quotes, even when they’re composed of a single word.


I tried the simple

#!/bin/sh
while read key name extra
do
    echo "myscript $key \"$name\" -- \"$extra\""
    #myscript $key "$name" "$extra"
done < list.txt

but it doesn’t group the value inside quotes in a single shell variable.
The output is

myscript 8723 ""full" -- "name" "more data here""
myscript #5002 ""another" -- "name" "bla bla bla""
myscript 7129 ""single"" -- "blablabla"
myscript 3910 "noquote" -- ""bla bla bla""

Instead, I’d like to obtain

myscript 8723 "full name" -- "more data here"
myscript 7129 "single" -- "blablabla"
myscript 3910 "noquote" -- "bla bla bla"

Of course I can add myscript to every line of the original text file and make that file a script or write a C program to do that …

  • 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-22T14:34:09+00:00Added an answer on May 22, 2026 at 2:34 pm
    #!/bin/sh
    while read key name extra
    do
        eval myscript $key $name $extra
    done <(grep -v "^#" list.txt)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I isolate touch events from each other? For example, I have one
The purpose of the <bdi> tag in HTML5 is to isolate bidirectional text from
How could I isolate just the text from this dropdown box code into a
I want to isolate all my code from the IoC container library that I
I need to isolate user-written code snippets from each other in javascript. For now
I'm trying to isolate a specific field in a SQL dump file so I
My understanding is that you have to write unit tests that isolate functionality. So
In the following example (apologies for the length) I have tried to isolate some
I'm trying to isolate duplicates in a 500MB database and have tried two ways
Here's my test code to isolate the problem: open Microsoft.FSharp.Metadata [<EntryPoint>] let main args

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.