IF -a condition meaning. | Unix Linux Forums | UNIX for Dummies Questions & Answers

  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 Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-30-2013
abhi_123 abhi_123 is offline
Registered User
 
Join Date: Jun 2008
Last Activity: 26 June 2014, 12:49 AM EDT
Posts: 39
Thanks: 2
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 10-30-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 29 August 2014, 5:55 PM EDT
Location: Galactic Empire
Posts: 3,362
Thanks: 230
Thanked 1,197 Times in 1,125 Posts
Refer: Expressions used with if
Sponsored Links
    #3  
Old 10-30-2013
abhi_123 abhi_123 is offline
Registered User
 
Join Date: Jun 2008
Last Activity: 26 June 2014, 12:49 AM EDT
Posts: 39
Thanks: 2
Thanked 0 Times in 0 Posts
Thanks a lot Yoda for the help.
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 10-30-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 29 August 2014, 5:55 PM EDT
Location: Galactic Empire
Posts: 3,362
Thanks: 230
Thanked 1,197 Times in 1,125 Posts
Quote:
Originally Posted by abhi_123 View Post
Thanks a lot Yoda for the help.
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 10-30-2013
Scrutinizer's Avatar
Scrutinizer Scrutinizer is online now Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 1 September 2014, 3:36 AM EDT
Location: Amsterdam
Posts: 9,372
Thanks: 272
Thanked 2,341 Times in 2,101 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 Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 03:38 AM.