Thread: Bash Script Q

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    752

    Question Bash Script Q

    I have a script which, in part, does this...
    • 1. Read in the first command line argument.
    • 2a. If the argument looks like an absolute path (starts with '/'?), follow code path a.
    • 2b. If the argument looks like a relative path (doesn't start with '/'?), follow code path b.


    So... I probably just haven't thrown enough time at it, but how the heck do I make this distinction? I know I could just look at the first character in the argument, but how do I do that?
    Callou collei we'll code the way
    Of prime numbers and pings!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    http://en.wikipedia.org/wiki/Bash
    Scroll down to the "regex" bit
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 04-10-2009, 12:57 AM
  2. Linux: Use C to call a bash script
    By harada in forum Linux Programming
    Replies: 9
    Last Post: 10-27-2006, 01:59 PM
  3. Script in games
    By Shakti in forum Game Programming
    Replies: 7
    Last Post: 09-27-2006, 12:27 AM
  4. Passing arguments to script.....
    By suwie in forum C Programming
    Replies: 5
    Last Post: 09-25-2004, 11:10 PM
  5. Game structure, any thoughts?
    By Vorok in forum Game Programming
    Replies: 2
    Last Post: 06-07-2003, 01:47 PM