return to first page linux journal archive
keywordscontents
Home  >  Magazine  >  #64 August 1999  >  Bash Prompt  >  Listing 1
Friday, June 25, 1999 | Last Updated 1:30 pm

Listing 1. Shell Script for Use in Prompt

#!/bin/bash
# lsbytesum - sum the number of bytes in a # directory listing TotalBytes=0 # cut below could fail - sed would be a good # alternative? for Bytes in $(ls -l | grep "^-" | cut -c30-41) do let TotalBytes=$TotalBytes+$Bytes done TotalMeg=$(echo -e "scale=3 \n$TotalBytes/1048576\ \nquit" | bc) echo -n "$TotalMeg"