The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Spliting file based on condition Raamc Shell Programming and Scripting 2 05-15-2008 08:51 AM
How to parse through a file and based on condition form another output file sivasu.india UNIX for Advanced & Expert Users 6 02-28-2008 12:59 AM
Read file based on condition sbasetty Shell Programming and Scripting 5 01-31-2007 10:54 PM
Splitting a file based on some condition and naming them srivsn Shell Programming and Scripting 1 12-07-2005 07:27 AM
awk script to split a file based on the condition superprogrammer Shell Programming and Scripting 12 06-14-2005 12:59 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-01-2008
Registered User
 

Join Date: Feb 2008
Posts: 2
Stumble this Post!
Moving file to directory based on condition.

Can any one help me to correct following script.

I have 2 directories DropZone and ProcessZone. File pattern is *VEHDESCSUM*.
Finding the 'no of files' in DropZone directory using ls *VEHDESCSUM* |wc -l
If DropZone has more than one file or 0 files then exit 1
If DropZone has one file then move file from DropZone to ProcessZone.

I am trying with the following code. But I am getting errors.

#!/bin/sh
##########################################################

DROP_ZONE=/apps/dsadm/GMCCi2/DropZone
PROCESS_ZONE=/apps/dsadm/GMCCi2/ProcessZone

echo ${DROP_ZONE}
echo ${PROCESS_ZONE}

cd $DROP_ZONE

cnt = ls *VEHDESCSUM* |wc -l

echo ${cnt}
if [ cnt -gt 1 ]
then
exit 1
else
mv $DROP_ZONE/*VEHDESCSUM* $PROCESS_ZONE
exit 0
fi

##########################################################


thanks for all
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-01-2008
Registered User
 

Join Date: Jul 2006
Posts: 183
Stumble this Post!
I think you have to use "$cnt" inside the bracket where you are checking for > 1
Reply With Quote
  #3 (permalink)  
Old 02-02-2008
Registered User
 

Join Date: Feb 2008
Posts: 2
Stumble this Post!
I have done changes above script. But still getting errors: "argument expected" Could you please any one correct my script.
========================================

DROP_ZONE=/apps/dsadm/GMCCi2/DropZone
PROCESS_ZONE=/apps/dsadm/GMCCi2/ProcessZone

echo ${DROP_ZONE}
echo ${PROCESS_ZONE}

cd $DROP_ZONE

echo FILE_COUNT = ls *VEHDESCSUM* |wc -l

if [ $FILE_COUNT -ne 1 ]
then
exit 1
else
mv $DROP_ZONE/*VEHDESCSUM* $PROCESS_ZONE
exit 0
fi
=================================
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0