HT201456: Boot Camp 5.1: Frequently asked questions

Learn about Boot Camp 5.1: Frequently asked questions
SkyGuy913

Q: How to stop a Terminal process when a file becomes to large?

I was making a terminal program to produce a txt file with incrementing numbers every line. But do to time and size I had wished the program to stop when it produced a txt file larger than 1GB here is the code I was using.

 

#!/bin/bash

main()

{

    cd ~/desktop

    a=0

    b=1

    a=`expr $a + 1`

    echo $a

    echo $a >> count.txt

    run

}

count()

{

    b= du -skL count.txt  > /dev/null       ///// problem here //// run it with out the comment to see how

    a=`expr $a + 1`

    clear

    echo "#"$a "-" $b"KB"

    echo $a >> count.txt

}

run()

{

    cd ~/desktop

    while [ $b -lt 1048576 ]

    do

        count

    done

}

main

MacBook, OS X Mountain Lion (10.8.4)

Posted on Aug 1, 2013 9:26 AM

Close

Q: How to stop a Terminal process when a file becomes to large?

  • All replies
  • Helpful answers