The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find and replace command in one line using one command vasikaran UNIX for Dummies Questions & Answers 10 08-20-2008 10:40 AM
Getting Command line on HP-UX rucha_mahajan HP-UX 2 05-12-2008 04:06 AM
how to? launch command with string of command line options TinCanFury Shell Programming and Scripting 5 04-28-2008 06:06 PM
Add line command felixwhoals UNIX for Dummies Questions & Answers 3 12-17-2007 12:12 AM
how to tell which OS via command line hankooknara UNIX for Dummies Questions & Answers 4 05-15-2007 11:39 PM

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

Join Date: Jun 2005
Posts: 15
Use of IF command in the command line.

What is the command line syntax for the if exist command in Unix like in DOS/WIN which test for the existance of a file?

Is the syntax the same in a script?

Thanx
  #2 (permalink)  
Old 06-22-2005
Simerian Simerian is offline
Registered User
  
 

Join Date: Oct 2003
Location: United Kingdom
Posts: 37
A couple of options

.ksh

if [[-f filename]] for existence

If I can remember correctly...

if [[-s filename]]for non-empty
  #3 (permalink)  
Old 06-22-2005
hugow hugow is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 15
Does this syntax work on the command line?

I am getting a ">" back from my command.
  #4 (permalink)  
Old 06-22-2005
Simerian Simerian is offline
Registered User
  
 

Join Date: Oct 2003
Location: United Kingdom
Posts: 37
yeah..., that is the continuation marker.

You can type:

if [[ -f filename]] then [ENTER]
echo "File exists" [ENTER]
else [ENTER]
echo "File does NOT exist" [ENTER]
endif [ENTER]

...and it should respond accordingly
Sponsored Links
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 06:12 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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