![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Tcp_conn_req_max_q (CASE-sensitive?) | Olli.Lang | SUN Solaris | 4 | 09-11-2008 04:03 AM |
| case sensitive "if [ -e $file ]"? | jul | Shell Programming and Scripting | 2 | 05-08-2008 09:48 AM |
| Ignore case sensitive in Case Switch | annelisa | Shell Programming and Scripting | 1 | 07-13-2006 05:36 AM |
| how to disable case sensitive on RHEL ? | blesets | UNIX for Dummies Questions & Answers | 2 | 04-02-2006 10:47 PM |
| Is Hostname Case sensitive ????? | ajphaj | UNIX for Dummies Questions & Answers | 3 | 02-16-2006 01:10 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
||||
|
Check if file is directory (-d) using case sensitive
Hi,
I am writing a bash script. At the beginning of the script there is a user defined variable which is a directory in which processed data will be moved. When running the script I would like to immediately make sure that the directory exists, and if not the script will error. The following code should do that: OUTDIR='/Users/msb65/test_data' if [ -d $OUT_DIR ]; then echo '- OUT_DIR exists' else echo; echo; echo 'ERROR: OUT_DIR does not exist' exit 1 fi However, this test does NOT seem to be case sensitive. How can I make it so it is? Thanks. Mike |
|
||||
|
First off [[ -d dirname ]] is case sensitive. Either there is another directory which matches or your script is doing something you do not want it to do in this case.
Is that code above identical to what is failing for you? |
|
||||
|
Hi Ikon,
That is interesting that similar code appears to be working differently on our two systems. I am using a Mac running Leopard. I wonder if there are nuances between our bash? On my system there is the directory: /Users/msb65/test_data/Olive However, the test doesnt error when I substitute a lowercase "o" on "Olive": $ dir='/Users/msb65/test_data/Olive' $ if [ -d $dir ]; then echo hello; fi hello dir='/Users/msb65/test_data/olive' $ if [ -d $dir ]; then echo hello; fi hello Why is this? Mike |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|