Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    How to remove extra space in argument to shell script

    I have a shell script which accepts 4 arguments

    to execute the script a b c d

    In the script I set

    When it works, I'll have F1=a, F2=b, F3=c and F4=d
    I did not create the caller program. But when they make the call with an extra space between the arguments, it kills my script

    for example, when they issue a b c d (an extra space between a and b

    I think my script will get F1=a F2= F3=b F4=c and it will fail because the F values are wrong.

    What is the best way to check and fix the problem (i.e to protect myself from being killed). I can't do nothing about the caller mistakes.

  2. #2
    Linux Engineer
    Join Date
    Apr 2012
    Virginia, USA
    You could parse $@ manually.

  3. #3
    Linux Engineer docbop's Avatar
    Join Date
    Nov 2009
    Woodshed, CA

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts