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
Split file into multiple files depending upon first 4 digits deepakgang Shell Programming and Scripting 4 04-09-2008 01:21 AM
split file depending on content Chaitrali Shell Programming and Scripting 4 11-14-2007 09:15 AM
while - comparision sharif Shell Programming and Scripting 2 11-01-2007 05:58 AM
How can I rename multiple files depending on a string occuring in the filenames? karman UNIX for Dummies Questions & Answers 6 05-22-2007 02:29 PM
Invoke script depending on previous scripts mpang_ Shell Programming and Scripting 0 06-26-2006 02:27 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-12-2007
mr_bold mr_bold is offline
Registered User
  
 

Join Date: Jan 2007
Location: UB, Mongolia
Posts: 32
Do commands depending on the comparision

Dear all,

I am writing a shell, that do commands if the file count reaches 96. I wrote a shell, but doesn't work
Code:

#!/bin/sh
MIN_FILE_COUNT=96;
GET_PATH=/home/collection/data1; export GET_PATH

FILES_COUNT=`ls $dirname | wc -l`

if [ $FILES_COUNT > $MIN_FILE_COUNT ] then
echo "commands listed here"
fi


test.sh: line 9: syntax error near unexpected token `fi'
test.sh: line 9: `fi'

Thank you very much
  #2 (permalink)  
Old 04-12-2007
msridh msridh is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 4
Try this way.

#!/bin/ksh

MIN_FILE_COUNT=96
GET_PATH=/home/tcsmosr/tcsids; export GET_PATH

FILES_COUNT=`ls $dirname | wc -l`

if [ $FILES_COUNT -gt $MIN_FILE_COUNT ]
then
echo "commands listed here"
fi

Thanks and Regards,
msridh
  #3 (permalink)  
Old 04-12-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Code:
if [ $FILES_COUNT > $MIN_FILE_COUNT ] then
should be
Code:
if [ $FILES_COUNT > $MIN_FILE_COUNT ]; then
  #4 (permalink)  
Old 04-12-2007
mr_bold mr_bold is offline
Registered User
  
 

Join Date: Jan 2007
Location: UB, Mongolia
Posts: 32
Thumbs up

Thanks to all.

Also this code works.

Code:
if awk 'BEGIN{if ('$FILES_COUNT' >= '$MIN_FILE_COUNT'); else exit 1}'
then
    echo true
else
    echo false
fi
  #5 (permalink)  
Old 04-12-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
if (( FILES_COUNT > MIN_FILE_COUNT )); then
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 09:36 PM.


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