Unix/Linux Go Back    


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 !!

IF -a condition meaning.

UNIX for Dummies Questions & Answers


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-30-2013
abhi_123 abhi_123 is offline
Registered User
 
Join Date: Jun 2008
Last Activity: 13 October 2014, 10:03 PM EDT
Posts: 42
Thanks: 5
Thanked 0 Times in 0 Posts
IF -a condition meaning.

Hi All,

Could you please let me know what is the meaning of below -a condition if the if?


Code:
if ! [ -a $SOURCEPATH/$SOURCEFILE_A ]

Thanks in advance for the help.

Last edited by Scrutinizer; 10-30-2013 at 12:14 PM.. Reason: code tags added
Sponsored Links
    #2  
Old Unix and Linux 10-30-2013
Yoda's Unix or Linux Image
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 22 May 2015, 10:54 AM EDT
Location: Galactic Empire
Posts: 3,402
Thanks: 240
Thanked 1,216 Times in 1,142 Posts
Refer: Expressions used with if
Sponsored Links
    #3  
Old Unix and Linux 10-30-2013
abhi_123 abhi_123 is offline
Registered User
 
Join Date: Jun 2008
Last Activity: 13 October 2014, 10:03 PM EDT
Posts: 42
Thanks: 5
Thanked 0 Times in 0 Posts
Thanks a lot Yoda for the help. Linux
And what is the difference between -a and -f.
It says -f is for regular file and -a is it for any file. Am i correct.?
    #4  
Old Unix and Linux 10-30-2013
Yoda's Unix or Linux Image
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 22 May 2015, 10:54 AM EDT
Location: Galactic Empire
Posts: 3,402
Thanks: 240
Thanked 1,216 Times in 1,142 Posts
Quote:
Originally Posted by abhi_123 View Post
Thanks a lot Yoda for the help. Linux
And what is the difference between -a and -f.
It says -f is for regular file and -a is it for any file. Am i correct.?
That is correct.

E.g. you can verify this by creating a named pipe (FIFO) using mkfifo:

Code:
$ mkfifo file.pipe
$ [ -a file.pipe ] && echo "True" || echo "False"
True
$ [ -f file.pipe ] && echo "True" || echo "False"
False

Sponsored Links
    #5  
Old Unix and Linux 10-30-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 25 May 2015, 4:34 AM EDT
Location: Amsterdam
Posts: 10,209
Thanks: 333
Thanked 2,694 Times in 2,410 Posts
Note: -a may happen to be supported for historical reasons, however, it is not part of POSIX so -e should be used instead.

Quote:
An early proposal used the KornShell -a primary (with the same meaning), but this was changed to -e because there were concerns about the high probability of humans confusing the -a primary with the -a binary operator.
test: Rationale
The Following User Says Thank You to Scrutinizer For This Useful Post:
Yoda (10-30-2013)
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
If condition return 0 even when it fails to satisfy te condition Priya Amaresh Shell Programming and Scripting 2 05-10-2013 01:54 AM
redirect stdout echo command in condition A run in condition B jao_madn Shell Programming and Scripting 3 11-02-2011 09:01 PM
Difference between [condition] and [[condition]] and ((condition)) when used with if condition soumyabubun HP-UX 2 05-06-2011 01:03 PM
meaning of !* busyboy Shell Programming and Scripting 3 06-14-2010 05:50 AM
meaning of ${0%${0##*/}} nyelavarthy AIX 7 09-23-2008 02:48 AM



All times are GMT -4. The time now is 05:28 AM.