<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:14pt;font-family:Luxi Mono">
<p>On Wednesday 11 January 2006 08:29, Jon Miller wrote:</p>
<p><span style="color:#007f00">> I could use some help in creating a program for a task that I need to do.</span></p>
<p><span style="color:#007f00">> I would like to know if there is a function in bash scripting or that can be used in a bash script that can determine the size of a file.</span></p>
<p><span style="color:#007f00">> What I need to do is to compare the file size of "A" against file "B", not sure if this possible in bash scripting.</span></p>
<p><span style="color:#007f00">> Also in the script cat A >> B doesn't seem to work.</span></p>
<p><span style="color:#007f00">> Need to read in the listing of a text file to get names from it, when finish with the various functions read the next name on the list and repeat the functions.</span></p>
<p><span style="color:#007f00">> </span></p>
<p><span style="color:#007f00">> </span></p>
<p><span style="color:#007f00">> Thanks</span></p>
<p><span style="color:#007f00">> </span></p>
<p></p>
<p><span style="color:#007f00">make sure the files are readable - try</span></p>
<p><span style="color:#007f00">chmod +w B</span></p>
<p></p>
<p>#!/bin/sh</p>
<p></p>
<p>declare -a FILES</p>
<p>FILES_<span style="color:#ff0000">CNT</span>=0</p>
<p></p>
<p>for x in `ls *`</p>
<p> do</p>
<p> FILES[$FILES_<span style="color:#ff0000">CNY</span>]="$x"</p>
<p> let FILES_<span style="color:#ff0000">CNT</span>+=1</p>
<p> done</p>
<p></p>
<p>function file_size ()</p>
<p>{</p>
<p> F1=`ls -s --block-size=1 $1`</p>
<p> echo "${F1%%' '*}"</p>
<p>}</p>
<p></p>
<p>for (( x=0 ; x<${FILES_<span style="color:#ff0000">CNT</span>} ; x++ ))</p>
<p> do</p>
<p> for (( y=${x}+1 ; y<${FILES_<span style="color:#ff0000">CNT</span>} ; y++ ))</p>
<p> do</p>
<p> if test `file_size ${FILES[$x]}` -<span style="color:#ff0000">eq</span> `file_size ${FILES[$y]}`</p>
<p> then</p>
<p> echo ${FILES[$x]} same size as ${FILES[$y]}</p>
<p> if diff-q ${FILES[$x]} ${FILES[$y]}</p>
<p> then</p>
<p> echo ${FILES[$x]} same as ${FILES[$y]}</p>
<p> fi</p>
<p> <span style="color:#ff0000">fi</span></p>
<p> done</p>
<p> done</p>
<p>do help test for more details</p>
<p></p>
<p>-- </p>
<p>regs MR E_T</p>
<p>_______________________</p>
<p>\ \</p>
<p> \ <span style="color:#ff0000">OOHH</span> I hate TYPOS \</p>
<p> \ \</p>
<p> ~~~~~~~~~~~~~~~~~~~~~~~</p>
<p></p>
</body></html>