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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:53:45+00:00 2026-06-08T11:53:45+00:00

The output of my script is tab delimited using awk as : awk -v

  • 0

The output of my script is tab delimited using awk as :

awk -v variable=$bashvariable  '{print variable"\t single\t" $0"\t double"}' myinfile.c

The awk command is run in a while loop which updates the variable value and the file myinfile.c for every cycle.
I am getting the expected results with this command .
But if the inmyfile.c contains a blank line (it can contain) it prints no relevant information. can I tell awk to ignore the blank line ?

I know it can be done by removing the blank lines from myinfile.c before passing it on to awk .
I am in knowledge of sed and tr way but I want awk to do it in the above mentioned command itself and not a separate solution as below or a piped one.

sed '/^$/d' myinfile.c
tr -s "\n" < myinfile.c

Thanks in advance for your suggestions and replies.

  • 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-08T11:53:46+00:00Added an answer on June 8, 2026 at 11:53 am

    There are two approaches you can try to filter out lines:

    awk 'NF' data.txt
    

    and

    awk 'length' data.txt
    

    Just put these at the start of your command, i.e.,

    awk -v variable=$bashvariable 'NF { print variable ... }' myinfile
    

    or

    awk -v variable=$bashvariable 'length { print variable  ... }' myinfile
    

    Both of these act as gatekeepers/if-statements.

    The first approach works by only printining out lines where the number of fields (NF) is not zero (i.e., greater than zero).

    The second method looks at the line length and acts if the length is not zero (i.e., greater than zero)

    You can pick the approach that is most suitable for your data/needs.

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

Sidebar

Related Questions

I have this warning every time I run my CGI-script (output is rendered by
In shell script i need to redirect output from dd command to /dev/null -
I'm using the CSV module to read a tab delimited file. Code below: z
Why this awk script: awk '{FS = \t ; print $1 - $2}' A.txt
Today I have just thrown together this PowerShell script which takes a tab-delimited text
The problem I have a tab delimited input file that looks like so: Variable
I wrote a script to reformat a tab-delimited matrix (with header) into a long
I'm writing a script to output Google Analytics API data and insert it into
I need to output some text as bash script, but in a script. I
This script successfully generated the pdfs to a folder tmp/.... However the ZIP output

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.