![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to add files to an existing tar file - HP-UNIX | Nomaad | UNIX for Dummies Questions & Answers | 5 | 3 Weeks Ago 02:27 AM |
| What's wrong with this line: if ${TEST:?} ; then echo empty; fi | meili100 | UNIX for Dummies Questions & Answers | 2 | 02-23-2008 08:45 AM |
| existing file to a fixed length file | cmanand | Shell Programming and Scripting | 3 | 01-25-2008 02:50 PM |
| Creating a csv file based on Existing file | skywayterrace | Shell Programming and Scripting | 3 | 12-02-2007 06:19 AM |
| i want to delete a file based on existing file in a directory | srivsn | Shell Programming and Scripting | 3 | 04-11-2006 01:38 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
if test for empty and non-existing file
How to write this condition in ksh?
if myfile is empty or myfile does not exist then do action1 fi is this OK? if [[ -s "$myfile" ]] -o [[ -f "$myfile" ]] then then do action1 fi Thanks. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Quote:
Code:
if [[ -s "$myfile" -o -f "$myfile" ]] ; then #do action1 fi vino |
|
#3
|
|||
|
|||
|
Actually this did not work on HP-UX
However replacing the -o with || works [[ cond1 || cond2 ]] why is ksh so strange??? Last edited by GNMIKE; 10-20-2005 at 12:29 PM. |
|
#4
|
||||
|
||||
|
From man ksh
Code:
[[ expression ]]
Similar to the test and [ ... ] commands (described later), with
the following exceptions:
o Field splitting and file name generation are not per-
formed on arguments.
o The -a (and) and -o (or) operators are replaced with &&
and ||, respectively.
|
||||
| Google The UNIX and Linux Forums |