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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:09:47+00:00 2026-05-11T15:09:47+00:00

working with cygwin and writing a script to show my my current ip address

  • 0

working with cygwin and writing a script to show my my current ip address minus 2. For some reason it is giving me the follwing error: ‘)syntax error: invalid arithmetic operator (error token is ‘

this is the script I am using.

$ cat test3.sh #!/bin/bash # function IPADDRESS {      v=$4     echo $1.$2.$3.$((v-2))  } ADDRESS=$(ipconfig | grep Address | cut -f2 -d :) # echo $ADDRESS IPADDRESS ${ADDRESS//\./ } 

any help or suggestion is apprieciated!

  • 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. 2026-05-11T15:09:47+00:00Added an answer on May 11, 2026 at 3:09 pm

    You’ve actually got a couple of problems with that script. The major one is that ipconfig will output ‘\r’ characters at the end of the line which stuffs up the calculation.

    Another is that you’re not allowing for multiple NICs, hence my 'head -1' addition. You’ll need to select which NIC you want a little more intelligently.

    And finally, I stripped out the leading space (actually all spaces) from the front of the IP address.

    The following works for me:

    #!/bin/bash #set -x  function IPADDRESS {     ((v = $4 - 2))     echo $1.$2.$3.$v } ADDRESS=$(ipconfig | grep Address | head -1 | cut -f2 -d: | sed 's/[ \r]//g') echo $ADDRESS IPADDRESS $ADDRESS 

    outputting:

    192.168.91.7 192.168.91.5 

    Actually, my version output the following:

    192.168.91.1 192.168.91.-1 

    so you’ll need to watch out for that.

    I’m no stranger to dummying up the output to impress/cajole management :-).

    USEFUL SNIPPET:

    The 'set -x' at the top of the script (when un-commented) is ideal for finding these sorts of errors. It outputs each line after all the substitutions but before executing, so that you can see exactly what’s going on.

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

Sidebar

Ask A Question

Stats

  • Questions 249k
  • Answers 250k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to escape the variables properly and surround them… May 13, 2026 at 9:12 am
  • Editorial Team
    Editorial Team added an answer You can use the Custom Build Step property page to… May 13, 2026 at 9:12 am
  • Editorial Team
    Editorial Team added an answer Adding the JBoss repository in NetBeans is one thing but… May 13, 2026 at 9:12 am

Related Questions

I have lots of directories with text files written using (g)vim, and I have
I am wondering how I can define an object in C whose reference will
I am facing some strange behavior with file-name completion in emacs. C-x C-f to
Is there a simple way to translate an XLS to a CSV formatted file

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.