Oct

Command line octal file permissions

Why?

Oct is a sample RubyGem application cloned from BasicApp. See http://github.com/robertwahler/basic_app for more information.

Oct does scratch an itch. 'Chmod' is easier to drive in octal and I can't convince 'ls -l' to output permissions in octal.

Here is an equivalent bash script

#!/bin/bash
# octal file listing

if [ "$1" == "" ]
then
  PARAM="*"
else
  PARAM="$@"
fi

for file in $PARAM
do

  if [ ! -e "$file" ]       # Check if file exists.
  then
    echo "$file does not exist."; echo
    continue                # On to next.
   fi

   stat --format='%a,%U,%G,%t %n' $file
done

Run-time dependencies

Development dependencies

Installation

This gem has been published on RubyGems.org

gem install oct

Usage

oct --help

Octal file listing

  Usage: oct [options] [FILES]

Options:

    -v, --[no-]verbose               Run verbosely
    -c, --[no-]coloring              Ansi color in output
        --version                    Display current version
    -h, --help                       Show this message

Example

ls -l

total 0
-rw-r--r-- 1 robert robert 0 2010-03-12 10:37 file1.txt
-rw-r--r-- 1 robert robert 0 2010-03-12 10:37 file2.txt

oct

0644 file1.txt
0644 file2.txt

Copyright (c) 2010-2011 GearheadForHire, LLC. See LICENSE for details.