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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:21:29+00:00 2026-05-16T08:21:29+00:00

How do I get the option -10 from command line arguments- tail -10 .

  • 0

How do I get the option -10 from command line arguments- “tail -10“. getopt function finds ‘1’ character. But how do I access the string “10”?

If this can be done by getopt_long, an example would help. Thanks.

  • 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-16T08:21:30+00:00Added an answer on May 16, 2026 at 8:21 am

    Unless you intend for -1 to be an option with 0 as its argument, the answer is you don’t. getopt is only made for processing options that fit the standard POSIX utilities’ option syntax. It may be possible to use GNU getopt_long for this purpose, or you could just write your own argv parser (it’s easy).

    Edit: Actually I think I misread what you want. If you want - followed by any number to be interpreted as an option with that numeric value, I don’t think there’s any version of getopt that will work. There’s no way you can special-case every single number as an option, and if you simply tell getopt that all of the digits are option characters that take arguments, -123 will be interpreted as a -1 option with an argument of 23 (which is fine, you can interpret it from there), but a lone -1 will cause the next argv element to get eaten as an argument to -1, which is difficult or impossible to recover from.

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

Sidebar

Related Questions

I am trying to get three arguments from command line: -o (for outputfile) -k
From the documentation I can see I can access command line arguments (command-line-args). I'd
When running ant from command line on my Netbeans projects, I get the following
When using optparse i want to get the whole string after an option, but
Quoting from docs.python.org : sys.argv The list of command line arguments passed to a
How does one get their current process ID (pid) from the Linux command line
I am trying to get the selected option from a dropdown and populate another
I need to get to work something like this: ./foo.py [-b option [-a]] with
I get the warning warning, -s option given but default rule can be matched
I'm tring to get some json to contain a function so that the option

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.