Thursday, Nov 8, 2012
Recently I have been doing quite a few more system administrator tasks around different office. I wrote this bash script (I realise it is probably not perfect to bash officianados, however, it does solve that problem). I have attached the completed file below if you want to download it.
Bash Code #!/bin/bash # get all users whose uid is greater than 1000 and less than 60000 for user in `awk -F':' '{if ($3 > 1000 && $3 < 60000) print $1}' /etc/passwd` do # create array as output from quota command array=( $(quota -v $user)) # retrieve amount of space user is using block=${array[17]} #retrieve quota that user is allowed quota=${array[18]} # result = quota - amount used result=$(($quota-$block)) # if result is less than 20000 then do something. ...
Connect on LinkedIn. Follow me on Twitter. Grab the RSS Feed