Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for file 1

Status
Not open for further replies.

sandeepmur

Programmer
Dec 14, 2003
295
PT
Hi,
I am using the command :
if [ test ! -s "$FILEPATH"tempTSSwap ] in a script to check if a file exists and am getting the fwg error message:

scripts>SGcheckSwap.sh
SGcheckSwap.sh[37]: !: A test command parameter is not valid.
SGcheckSwap.sh43]: /software/mon/scripts/tempTSSwap: Cannot find or open the file.

any suggestions as to whats wrong here ? I thought the "-s" flag was correct..

thnx
 
Use either:
if [ ! -s "$FILEPATH"tempTSSwap ]
Or:
if test ! -s "$FILEPATH"tempTSSwap

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thnx.. I removed the Braces and it worked but its strange because I have another script where the braces as I posted above and the script works fine..

Any reasons ?

thnx
 
one other thing, How do I extract 4 diff values from a file into 4 diff variables ??

ex. a file abc.txt has the entries
121354554
456
45787
45

I want each of the values in a different variable.

thnx
 
From my test man page:
Syntax
test expr
[ expr ]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
A starting point (in ksh-like shell):
set -A myArr $(<abc.txt)
echo "${myArr[0]},${myArr[1],${myArr[2]},${myArr[3]"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top