LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-05-2002, 06:24 AM   #16
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600

if [ -s "$destdir/$errlogfilename" -a "$sysadmin" != "" ]; then

(-s, condition unknown to me, use "-f" (file) or "-w" (writable)), so
if (something concerning) "$destdir/$errlogfilename" and (-o is or) value for $sysadmin not-is empty(""); then ...

a verbose way to write this would be:
if [ -s "$destdir/$errlogfilename" ]&&[ "$sysadmin" != "" ]; then
or even worse:
if [ -s "$destdir/$errlogfilename" ]; then if [ "$sysadmin" != "" ]; then

An example of "" would be` echo "\"$(true)\" \"$?\""`
You'll see "true" doesn't have output in the std channel (so "" shows only our escaped quotes), only stderr, which, in the case of true always shows "0" for OK.
 
Old 09-05-2002, 07:22 AM   #17
no2nt
Member
 
Registered: Aug 2001
Location: South Carolina, USA
Distribution: Redhat 8.0/Custom
Posts: 96

Rep: Reputation: 16
-s returns true if the file exists and is of length > zero
-a returns true if file exists

The double quotes around the variables exists just in case the
variables contain a space (ie. a filename like '/home/ben/my docs'). If
the quotes are not used the script is expanded such:
Code:
if [ -s /home/ben/my docs -a root != "" ]; then
and /home/ben/my and docs are expanded by bash as two parameters,
not one. Putting quotes around the variable would expand it to
"/home/ben/my docs".

More good stuff:
http://www.gnu.org/manual/bash/html_...f_6.html#SEC75
 
Old 09-05-2002, 08:01 AM   #18
BehMershal
LQ Newbie
 
Registered: Aug 2002
Location: Australia......mate
Distribution: Mandrake
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by no2nt
-s returns true if the file exists and is of length > zero
-a returns true if file exists
-a is mearly a logical and operator...

if [ -s "$destdir/$errlogfilename" -a "$sysadmin" != "" ]

equates to...if "$destdir/$errlogfilename" exists and is > 0 AND "$sysadmin" is not equal to ""

In the script i'm working on....the variable $sysadmin is an e-mail address....root@backup.blahblah

I just didn't see the meaning in "$sysadmin" != ""
 
  


Reply



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
Bash scripting pete1234 Programming 1 09-27-2005 01:48 AM
bash scripting.. kurrupt Programming 3 09-21-2005 12:07 AM
BASH Scripting ? eroica Programming 3 06-07-2004 07:51 PM
bash scripting -=MaGo=- Programming 16 08-30-2003 07:07 PM
Bash scripting kbeaver Programming 5 07-18-2003 08:35 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:00 AM.

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