Do commands depending on the comparision


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Do commands depending on the comparision
# 1  
Old 04-12-2007
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  
Old 04-12-2007
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  
Old 04-12-2007
Code:
if [ $FILES_COUNT > $MIN_FILE_COUNT ] then

should be
Code:
if [ $FILES_COUNT > $MIN_FILE_COUNT ]; then

# 4  
Old 04-12-2007
MySQL

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  
Old 04-12-2007
Code:
if (( FILES_COUNT > MIN_FILE_COUNT )); then

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split file depending on Column Value

Hi , my file look likes below , cat file.csv 12/09/2014,50,5,0,300 12/09/2014, ,5,0,300 12/09/2014,50,,,300 i need to split file , the first one contains values (2nd column is 50 , 3rd and fourth column is null ) the second file contains all others firstfile ... (2 Replies)
Discussion started by: ubaisalih
2 Replies

2. Shell Programming and Scripting

How to Split File to 2 depending on condition?

Hi , cat myfile.txt ! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.30.33 ! 3100.2.4.1 ! ! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.22.11 ! 3100.2.4.1 ! ! 3100.2.0.5 ! 3100.2.2.50 ! 3100.2.22.11 ! 3100.2.4.1 ! ! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.30.33 ! 3100.2.4.1 ! ! 3100.2.0.5 ! 3100.2.22.4 !... (6 Replies)
Discussion started by: OTNA
6 Replies

3. Shell Programming and Scripting

Parsing files depending on the content

I am trying to parse files kkapjil kkpcjil kkexjil ...which have autosys job names. The objective is to parse each file...do an autorep -j <job name > -q and write it as output with a line for condition at the end of the each job. The problem I am facing is with the box jobs...as autorep -j <box... (0 Replies)
Discussion started by: w020637
0 Replies

4. Shell Programming and Scripting

Add depending on the column

Hi all, If column 6 is negative then I want column 3 is be subtracted by 150. If column 6 is positive then I want 150 added to the value at column 2. The file that looks like this: Bull 38 158 HWI-ST600:206:D0L90ACXX:8:2214:15503:17988 0 -... (2 Replies)
Discussion started by: phil_heath
2 Replies

5. Shell Programming and Scripting

choosing executable depending on distro

Hi, I have an application in 2 different directories, one is for OpenSuSE and the other for CentOS. I wrote a script which chooses the right executable for the distribution. But it does not work. ------------------- #!/bin/bash if then ( DN="/home/apps/applicationXY/Version3.1" )... (2 Replies)
Discussion started by: serverjunge
2 Replies

6. Shell Programming and Scripting

To read xml value depending on property

Hi have some xml like this <example> <Cell Name="Cell1" ConfigureHost="claas" Role="APPSERV,BACKEND"> <Node Name="aaaaa" Role="APPSERV,BACKEND,CLM"/> <Node Name="vvvv" Role="APPSERV,BACKEND"/> <Mercury Type="default" FQDN="ssssss" PrimaryReturnFQDN=""/> </Cell> ... (1 Reply)
Discussion started by: javaholics
1 Replies

7. Shell Programming and Scripting

Replacing all occurences depending on parity

I want to replace all occurences of '$' in a LaTeX source code in the following way: The dollars on odd position in the file must be changed in '$latex ' and the other dollars can remain the same. I was thinking to make a script which replaces all odd occurences of a given character with a... (4 Replies)
Discussion started by: beni22sof
4 Replies

8. UNIX for Dummies Questions & Answers

exit status depending on output

Hi I have a script that does a select from a table. I want the script to return a 0 status if a specific column has 'OK' value or return 1 if this column returns 'NOT OK'. The output now is similar to: COL1 COL2 STATUS ------- --------- ------- I want to be limited to... (1 Reply)
Discussion started by: melanie_pfefer
1 Replies

9. Shell Programming and Scripting

To filter a certain pattern depending on neighbour

Hi, As I am new to filtering section of Unix I am facing a problem I have following lines in text file : Created RELEASE in dist/Apple_release_1_0_.zip Created RELEASE in dist/Banana_release_1_0_.zip Created RELEASE in dist/Mango_release_1_0_.zip Created RELEASE in... (2 Replies)
Discussion started by: bhaskar_m
2 Replies

10. Shell Programming and Scripting

while - comparision

Hi, Please find the attached scriplet and suggest me to fix the bug in this. ----------------------------------- noofdirs=`ls *.tar | wc -l` if ; then let i=1 while ( $i <= $noofdirs ) ; do echo $i mkdir $i file1=`ls *.tar | head -1` mv $file1 $i i =... (2 Replies)
Discussion started by: sharif
2 Replies
Login or Register to Ask a Question