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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:54:17+00:00 2026-06-09T17:54:17+00:00

I am using AWK script to process some logs. At one place I need

  • 0
  1. I am using AWK script to process some logs.
  2. At one place I need to check if the variable value is null or empty to make some decision.

Any Idea how to achieve the same?

awk '

{
    {
       split($i, keyVal, "@")
       key=keyVal[1];
       val=keyVal[2];
       if(val ~ /^ *$/)
       val="Y";

    }

}

' File

I have tried with

1) if(val == "")

2) if(val ~ /^ *$/)

not working in both cases.

  • 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-09T17:54:19+00:00Added an answer on June 9, 2026 at 5:54 pm

    The comparison with "" should have worked, so that’s a bit odd

    As one more alternative, you could use the length() function, if zero, your variable is null/empty. E.g.,

    if (length(val) == 0)
    

    Also, perhaps the built-in variable NF (number of fields) could come in handy? Since we don’t have access to your input data it’s hard to say though, but another possibility.

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

Sidebar

Related Questions

I'm trying to pull some data out of logs on remote machines using awk,
I write PSQL script and using variables (for psql --variable key=value commandline syntax). This
I'm using an awk script to do some reasonably heavy parsing that could be
I have a small awk script that does some in-place file modifications (to a
I am trying to run an awk script using python, so I can process
I am trying to print a particular text using awk if string is empty.
I am using awk to perform counting the sum of one column in the
I'm using awk to get the pid of a specific process by name. #!/bin/sh
I am currently writing an awk script within a bash script. One of my
I'm using the following awk command in an expect script to get the gateway

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.