[ ! -e a.log ] & [ ! -f a.log ] difference b/w these two


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [ ! -e a.log ] & [ ! -f a.log ] difference b/w these two
# 1  
Old 12-18-2008
[ ! -e a.log ] & [ ! -f a.log ] difference b/w these two

Code:
if [ ! -e a.log ]; then
        touch a.log
fi

...................................

if [ ! -f a.log ]; then
        touch a.log
fi

Hi ,

Are the above two meant for same purpose i.e finding & creating a.log ?

I would really appreciate if you could explain the purpose of " ! " & " -f "
in these .

thanks
# 2  
Old 12-18-2008
Hi,
"Everything is a file..."
but not everything is a regular file.
-e return true (and ! reverse the result) if there exist something named a.log
-f return true (and ! reverse the result) if there is something named a.log and is a regular file,such as a text file or a binary, what most people think of as normal files.


Code:
lakris@ubuntu:~$ [ -e /dev/audio ] && echo true
true
lakris@ubuntu:~$ [ -f /dev/audio ] && echo true
lakris@ubuntu:~$

/Lakris

Last edited by Lakris; 12-18-2008 at 04:32 PM.. Reason: clarification
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

2 way to save a log file, what is the difference?

Hello good day I would like to know what is the difference between these two commands please both warrant the output in the file echo " ORACLE_SID : $ORACLE_SID" | tee -a $logfile echo " ORACLE_SID : $ORACLE_SID" > $logfile (3 Replies)
Discussion started by: tricampeon81
3 Replies

2. UNIX for Dummies Questions & Answers

Difference between & and nohup &

Hi All, Can anyone please help me understanding what the difference between the below two? 1. script.sh & 2. nohup script.sh & (2 Replies)
Discussion started by: Anupam_Halder
2 Replies

3. Shell Programming and Scripting

Need Script to ZIP/SAVE & then DELETE Log file & send a mail conformation for any error

ENVIROMENT Linux: RHEL 6.4 Log Path: /usr/iplanet/servers/https-company/logs Log Format: user.log.03-15-2015 I have log4j log rotation enabled rotating files on a daily basis. The rotated logs are NOT compressed & are taking up too much space. I need a script that will run daily that... (1 Reply)
Discussion started by: admin_job_admin
1 Replies

4. Shell Programming and Scripting

Check/Parse log file's lines using time difference/timestamp

I was looking at this script which outputs the two lines which differs less than one sec. #!/usr/bin/perl -w use strict; use warnings; use Time::Local; use constant SEC_MILIC => 1000; my $file='infile'; ## Open for reading argument file. open my $fh, "<", $file or die "Cannot... (1 Reply)
Discussion started by: cele_82
1 Replies

5. Red Hat

Need Script to ZIP/SAVE & then DELETE Log file & DELETE ZIPS older than 12 months

ENVIROMENT Linux: Fedora Core release 1 (Yarrow) iPlanet: iPlanet-WebServer-Enterprise/6.0SP1 Log Path: /usr/iplanet/servers/https-company/logs I have iPlanet log rotation enabled rotating files on a daily basis. The rotated logs are NOT compressed & are taking up too much space. I... (7 Replies)
Discussion started by: zachs
7 Replies

6. Shell Programming and Scripting

Log Analysis with AWK with Time difference

I would like to write a shell script that calculated the time difference bettween the log entries. If the time difference is higher as 200 sec. print the complette lines out. My Problem is, i am unable to jump in the next line and calculate the time difference. Thank you for your Help. ... (5 Replies)
Discussion started by: fabian3010
5 Replies

7. Shell Programming and Scripting

How can view log messages between two time frame from /var/log/message or any type of log files

How can view log messages between two time frame from /var/log/message or any type of log files. when logfiles are very big and especially many messages with in few minutes, I would like to display log messages between 5 minute interval. Could you pls give me the command? (1 Reply)
Discussion started by: johnveslin
1 Replies

8. Shell Programming and Scripting

compare the log and display the time difference..

Hi All, I've written a script which reads all the systems backup information and saves it in a log file. #!/bin/ksh export ORACLE_SID=$1 export primaryhost=$2 export sid=`echo $ORACLE_SID| tr ` RESULTFILE=/oracle/PC9/backupstatus_prod.log LOGP=`ssh -o StrictHostKeyChecking=no -l... (1 Reply)
Discussion started by: suri.tyson
1 Replies

9. Shell Programming and Scripting

To find the time difference between two lines of the same log file

Hello Friends, I want to write a script for the following: nlscux62:tibprod> grep "2008 Apr 30 01:" SA_EHV_SPEED_SFC_IN_03-SA_EHV_SPEED_SFC_IN_03-2.log | grep -i post | more 2008 Apr 30 01:01:23:928 GMT +2 SAPAdapter.SA_EHV_SPEED_SFC_IN_03-SA_EHV_SPEED_SFC_IN_03-2 Info AER3-000095 IDOC... (2 Replies)
Discussion started by: satyakam
2 Replies

10. UNIX Desktop Questions & Answers

what is the difference between Unix & linux, what are the advantages & disadvantages

ehe may i know what are the difference between Unix & Linux, and what are the advantages of having Unix as well as disadvantages of having Unix or if u dun mind i am dumb do pls tell me what are the advantages as well as the disadvantages of having linux as well. thanks (1 Reply)
Discussion started by: cybertechmkteo
1 Replies
Login or Register to Ask a Question