Find the answer to your Linux question:
Results 1 to 2 of 2
I am new to this forum and new to scripting so please bare with me, thanks. Question: How do you have a user input a directory path and check to ...
  1. #1
    Just Joined!
    Join Date
    Dec 2008
    Posts
    1

    Need help with user input

    I am new to this forum and new to scripting so please bare with me, thanks.

    Question: How do you have a user input a directory path and check to see if that path exist??

    I need to have the user to input a directory path and then have my code check to see if the directory exist. If it exist then change to that directory and proceed with the rest of the code. If directory does not exist proceed within the current directory.

    example:

    echo "Please input the directory where the files are located"

    Thanks for all help in advanced.

    I am using bash on an apple powerbook g4.

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Out of curiosity, is this a homework assignment? Homework questions are not allowed on this forum.

    The best Bash guide that I have ever used is:
    Advanced Bash-Scripting Guide

    In particular, I will point you towards these sections:
    File test operators
    Internal Commands and Builtins (see the "read" command)

    Good luck!
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

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