The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Missing core file using ssh + command kclittle UNIX for Advanced & Expert Users 5 03-26-2008 05:36 PM
Urgent: How can i get the missing records from one file out of two Shiv@jad UNIX for Advanced & Expert Users 1 10-10-2007 03:43 PM
finding duplicate files by size and finding pattern matching and its count jerome Sukumar Shell Programming and Scripting 2 12-01-2006 04:20 AM
File descriptors missing on startup xnightcrawl UNIX for Advanced & Expert Users 1 12-23-2005 12:58 PM
core file missing part of call stack Lazzar AIX 1 07-29-2005 07:50 AM

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 06-22-2008
SAMZ SAMZ is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 18
Finding which file is missing

I was hoping someone ould help me with the following.

I have 2 files in a directory FILEA and FILEB. i am running a process on these 2 files but before the process can run both FILEA and FILEB need to be present.

If one or both the files are missing i need to know what file(s) is(are) missing. I am not entirely sure how to go about this problem with out using the 'test' command several nested if statements... i am sure there must be a better solution could anyone assist.

Thanks for your help.
  #2 (permalink)  
Old 06-22-2008
bankai bankai is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 23
What's the problem with doing nested if ?

Code:
if [ ! -f $FILEA ]
then
     if [ ! -f $FILEB ]
     then
          echo "Neither file exists"
     else
           echo "File A does not exist but file B does"
     fi
else
    if [ ! -f $FILEB ]
    then
          echo "File A exists but file B does not"
    fi
fi
  #3 (permalink)  
Old 06-24-2008
chachabronson chachabronson is offline
Registered User
  
 

Join Date: May 2008
Posts: 12
I was hoping someone could expand on this for me as it could be useful.
How would you do teh below but for different file names.

i.e. say on one day FILEA.TXT is called filea.txt, or FiLeA.tXT or even fIlEa.TxT. Say the case case changes but not the file name. so if the file being checked was always the same name but differed only it uppercase or lowercase how could you do a seach so file would be picked up irrespective of the case
  #4 (permalink)  
Old 06-24-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink Suggest review of 'tr' command based on last posting

do a
Code:
>man tr
and you will find out about its ability to translate characters all to one case as in the following

Code:
tr -s '[:upper:]' '[:lower:]'
  #5 (permalink)  
Old 06-24-2008
chachabronson chachabronson is offline
Registered User
  
 

Join Date: May 2008
Posts: 12
could you give me an example as my skills are pretty poor
have chacked man tr but am confused as to how i would use to process a file irrelevant of its case...

Plus tr only appears to accept input from stdin but in above example the inputs will be filea and fileb so am even more confused

any help
  #6 (permalink)  
Old 06-24-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink example of tr command

Code:
> file1="AbCdEf"
> file1a=$(echo "$file1" | tr [A-Z] [a-z])
> echo $file1a
abcdef
So, if you translate the filename to all lowercase, then do your comparisons, I think you will be in good shape.
Closed Thread

Bookmarks

Tags
linux, solaris

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 04:30 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