Need clarification on option in if


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need clarification on option in if
# 1  
Old 07-06-2009
Need clarification on option in if

Hi, I am analisying an existing script. what the below code will do?
if [ ! -a ${REF_file} ]
can some onle tell me what -a will do here. Upto my knowledge it can be used as and.
In this case they gave a comment like-- it will check for the existance of the ref file. I feel -f need to be used to check the existence.

Thanks in advance.
# 2  
Old 07-06-2009
test command has option -a and it same as -e, almost same as -f.
-e file exist
-f file exist and it's regular file
so: test ! -a "$REF_file" will test "if file not exist, then ..."

You can write test or using [ -command, in [ cmd last argument must be ]

if test -f file ; then ...
if [ test -f file ] ; then
are same builtin command

[ is not bracket, it's command

More about if

Last edited by kshji; 07-06-2009 at 02:11 PM..
# 3  
Old 07-07-2009
Thanks for your help...
Here -a is used with if but not with test. As u said can i consider it as -f or -e.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Unrecognized option: sparc-sun-Solaris2.10/bin/as: unrecognized option `-m32'

Hi, I installed some packages required by an app built with python. But when I try python setup.py install, I get the following error: /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.2.0/../../../../sparc-sun-solaris2.10/bin/as: unrecognized option `-m32' Could anyone tell me what's wrong... (4 Replies)
Discussion started by: Kimkun
4 Replies

2. Solaris

T5 Firmware clarification

Hello, I am going to upgrade the Firmware on a T5 Sparc server running Solaris 11.2 and just wanted to clarify a couple of things please. I have downloaded the Firmware patch P24441083_96, however this says it is based on ILOM 3.2.6. Ive been trying to find the download ilom 3.2.6 but each time... (2 Replies)
Discussion started by: rakeman
2 Replies

3. UNIX for Advanced & Expert Users

Need Clarification

Hi All, I have a file cleanlogs_imgp01_files which has the contents as follows, cold_log|/opt/elf/cold_spool get_orion_log|/opt/elf/logs get_coldFiles_log|/opt/elf/logs get_coldFiles_TuesToSat_log|/opt/elf/logs get_coldFiles_MonToSat_log|/opt/elf/logs And when i execute this, I get the... (1 Reply)
Discussion started by: DevM
1 Replies

4. Shell Programming and Scripting

permission clarification

crw-rw-rw- 1 root root 1, 5 May 6 1998 /dev/zero brw----rw- 1 root floppy 2, 28 May 6 1998 /dev/fd0H1440 In the above permission what is above C and B indicates? Thanks (1 Reply)
Discussion started by: thelakbe
1 Replies

5. UNIX for Advanced & Expert Users

Need clarification

We are facing problem while executin below script, cat $PIPE_FILE | imscp - "${LRX_FILE_LOC}" 2>&1 | tee "${LIST_DIR}/${IMSCP_OUT_FILE}" & sqlplus -s ${REPORTING_CONNECT} <<EOF whenever sqlerror exit 1 rollback spool ${PIPE_FILE} start ${LRX_EXEC_SQL} ${LRX_MDL_RUN_DATE} spool off exit... (4 Replies)
Discussion started by: samiks14
4 Replies

6. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

7. UNIX for Dummies Questions & Answers

Clarification regarding nohup.out

Hi, I am creating two shell scripts for Database backup and the output has to be routed to nohup.out file. We will also be running the scripts in the background as nohup.out <script_name> & Do I manually need to create a nohup.out file in the directory from where the scripts are going... (1 Reply)
Discussion started by: narayanv
1 Replies

8. Web Development

Clarification

:confused: Hi All, i am new to unix....so i am not sure whether i am asking the related question with our forum.. My question .....Can anyone explain me about the CGI script is it something related to Unix or Linux or some other language. Thanks in advance Sha (1 Reply)
Discussion started by: Shahul
1 Replies

9. Shell Programming and Scripting

option followed by : taking next option if argument missing with getopts

Hi all, I am parsing command line options using getopts. The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument. Below is the script: while getopts :hd:t:s:l:p:f: opt do case "$opt" in -h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies

10. Shell Programming and Scripting

Need clarification

Hi All, I am using Korn Shell HP UNIX and i am writing my scripts with filename extension as ksh or sh .. I want to know what is the difference if i am giving ksh and sh Other thing when we execute the shell script either we make it as executable and run directly else we give '.' or 'sh'... (2 Replies)
Discussion started by: ravi.sadani19
2 Replies
Login or Register to Ask a Question