![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ubuntu shell script | lucianvibz | Shell Programming and Scripting | 1 | 05-27-2008 10:47 AM |
| Need to write a script in UNIX to find a file if another file exists | mmdawg | Shell Programming and Scripting | 1 | 05-04-2008 11:40 PM |
| Check File Exists and compare to previous day file script | rbknisely | Shell Programming and Scripting | 3 | 02-07-2008 11:53 AM |
| unix script to check whether particular file exists and to find its size | Balachandar | Shell Programming and Scripting | 9 | 02-05-2008 03:56 AM |
| If file exists (bourne shell) | blakmk | UNIX for Dummies Questions & Answers | 2 | 11-19-2003 10:47 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Chek if a file exists in Ubuntu and Cent OS using shell script
I have tried few examples in the internet but all of them are different and none worked. I need to check if a file exists in a directory if it does not then exit . here is what I have for now
$filename ="/usr/local/net/var/lib/directoryservice/sync.disable" if [-e $filename ]; then echo "The file exists" else echo "Does not exist" fi This gives me error saying the ="/usr/local/net/var/lib/directoryservice/sync.disable" is not a directory or file and -e option does not exist. I need to be working on ubuntu and centos. Any help will be appreciated. Thank you. |
|
||||
|
You need a space between the opening square bracket and the -e. The opening square bracket -- believe it or not -- is the name of a command (also known as test) and like other commands, it needs to be its own space-separated token.
Also, you need to drop the dollar sign when assigning to a variable, and not have any spaces between the variable name, the equals sign, and the value. |
![]() |
| Bookmarks |
| Tags |
| linux, ubuntu |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|