The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
passing in arguments into a file using a loop eltinator Shell Programming and Scripting 11 04-14-2008 05:01 PM
Multiple loops for Load test willdev Shell Programming and Scripting 0 05-29-2006 04:25 PM
Can not test many arguments baton Shell Programming and Scripting 4 11-18-2005 08:12 AM
Reading runtime arguments from a file Sabari Nath S UNIX for Dummies Questions & Answers 4 08-24-2005 10:38 AM
arguments in sourcing file Nathe UNIX for Dummies Questions & Answers 4 08-23-2004 07:53 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-22-2005
cruiser cruiser is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 10
can't TEST multiple arguments for a file

Hi,
I'm new to scripting and teaching myself how to code. Using Korn, I coded this one return "True" if a file is executable and it's not empty. However, each time I pass a file that is 777 which contains data, the script returns "false".

if [ -x -a ! -s "$1" ]
then
echo "true"
else
echo "false"

fi

By the way..
I was successful using AND when validating strings instead of a file

What am I missing?
  #2 (permalink)  
Old 11-22-2005
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,813
I think you want:


Code:
if  [[ -x  "$1" && -s "$1" ]] ; then
    echo "true"
else
    echo "false"
fi

  #3 (permalink)  
Old 11-22-2005
cruiser cruiser is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 10
Makes sense to me and works fine.

Thank you, Jim!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0