LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-05-2016, 03:50 AM   #1
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Rep: Reputation: 103Reputation: 103
bash test -a ! -e


So, I'm trying to understand the following syntax which seems contradictory to me:

linkchk () {
for element in $1/*; do
[ -h "$element" -a ! -e "$element" ] && echo "$element"
[ -d "$element" ] && linkchk $element
# Of course, '-h' tests for symbolic link, '-d' for directory.
done

Doesn't -a and -e mean the same thing? It seems as though it were saying that $element should and should not exist at the same time.

source:
http://tldp.org/LDP/abs/html/
 
Old 08-05-2016, 05:06 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
In this context '-a' is logical 'and' see http://tldp.org/LDP/abs/html/comparison-ops.html
Prev page there shows the old defn of '-a' is deprecated and that page is old itself ...
 
1 members found this post helpful.
Old 08-05-2016, 06:46 AM   #3
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
I did read about it, but I didn't think it was out of use. There are many deprecated arguments, syntax structures, etc. that are deprecated, but they can still be used. So I didn't know about -a meaning 'and'. Indeed, I must have missed the definition of -a as a logical "and".

Thank you.
 
  


Reply

Tags
bash



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Test for integer in BASH minil Programming 18 02-01-2012 12:45 AM
test statement in bash casperdaghost Linux - Newbie 8 10-13-2011 07:16 AM
[SOLVED] [BASH] confused with test. RaptorX Programming 4 08-24-2009 03:21 PM
bash - syntax of if [ ] (test) bricedebrignaisplage Programming 2 06-04-2008 04:22 AM
BASH - For with a if test command mago Programming 9 05-03-2007 02:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration