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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:57:00+00:00 2026-06-10T06:57:00+00:00

Question : I’m breaking my teeths under this: awk -v full=wc -v empty=wp ‘{

  • 0

Question :

I’m breaking my teeths under this:

awk -v full=wc -v empty=wp '{
     ...blablabla...
     if ($4==full) stop=yes
     if (stop==yes && $4==empty) exit
     ...blablabla...
     }'

The code works well (I mean, I get an output) if I don’t declare the two variables full and empty at the beginning, and use instead the values of these in the script. If I only use the first variable in the script, I get the same output. But if I only use the second variable, I get no output at all.

  • 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-10T06:57:01+00:00Added an answer on June 10, 2026 at 6:57 am

    Consider what happens when the variables are expanded. A portion of the awk body goes from:

    ' ... if ($4=='$full') ...'
    

    to

    ' ... if ($4==wc) ...'
    

    Since wc is a “bare word”, awk thinks it is a variable and substitutes it’s value (empty string), so you get this:

    ' ... if ($4=="") ...'
    

    When you’re building your awk script, you need to be aware of quoting strings in awk. You need:

    ' ... if ($4=="'$full'") ...'
    

    However, it is much more elegant to pass values with awk’s -v option as you have done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Question Is it possible to stop a Message Driven Bean (programmatically), so that it
Question is relevant to this and this ; the difference is, I'd prefer something
Question How can I remove empty xml tags in PHP? Example: $value1 = 2;
Question: Considering the hello-gl2 example from Android NDK r6b, is this example correct when
Question is rather simple but I couldn't find nice & clean solution to my
Question What's the full code to enable jQuery on a page and then use
Question: Have I got this example backwards? Is the reason to return Interface so
Question Please note that the solution to this is directly below using Eugen's view
Question How can I get this sequence to fire when a user takes action

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.