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

  • Home
  • SEARCH
  • 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 8624879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:38:27+00:00 2026-06-12T07:38:27+00:00

I am running ubuntu11.10, and I think it uses mawk by default. Suppose I

  • 0

I am running ubuntu11.10, and I think it uses mawk by default. Suppose I have an awk script named ‘script.awk’, it receives one argument. Also I want to specify the name of the file I want to parse. So if I would use ’10’ as an argument to parse ‘file’, I should run:

./script.awk 10 file

However ’10’ gets interpreted as a file to parse, and not as the argument. I know I could use the -v flag to set an internal variable, but I would like to use ARGV to be able to check if the argument was passed, like:

if (ARGC < 2) { exit 1 }

Is there a workaround, or I will have to stick the -v flag?

  • 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-12T07:38:28+00:00Added an answer on June 12, 2026 at 7:38 am

    The BEGIN block in an awk script is executed before the arguments are used. That gives you an opportunity to check for the right number of arguments and make changes. There is a special behavior that if the argument is an empty string, it is skipped over, so you can do this:

      BEGIN {
        if (ARGC<3) exit(1);
        arg=ARGV[1]
        ARGV[1]=""
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple script that should cause one of three divs to be
I'm having a really strange problem. I have 2 virtual machines running ubuntu 11.4
I am running Intellij 11.0.1 on Ubuntu 11.10. I have installed some ttf fonts.
I am running Ubuntu 11.10 and have installed jdk-6u30-linux-i586.bin and have a directory /usr/local/jdk1.6.0_30
I'm running Ubuntu 11.10 and have run sudo apt-get install jenkins to install Jenkins
I'm running Ubuntu 11.10 and have installed rvm using the standard instructions listed here
At work, I have a desktop computer running Ubuntu 11.04 with VirtualBox installed. I
I am running Ubuntu 11.10 (Unity interface) and I created a Bash script that
I have tried everything I can think of to get this to work, to
I have had all sorts of bizarre errors, like the one in the title,

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.