Page 1 of 1

Trying to put name on gear on a mac

Posted: Wed Sep 25, 2019 5:12 am
by victorivitch
Any more tech savy folk out there know how to create a saf file on a mac? I'm struggling here.
Thanks!

Re: Trying to put name on gear on a mac

Posted: Wed Sep 25, 2019 7:08 am
by Wahlamt

Code: Select all

#!/bin/bash
#
# Simple Archive Format
#


#set -C

if test "_$1_" = _c_
then
   shift
   (for f in "$@"; do wc -c "$f"; done) | awk '{ print $1, $2; }'
   echo -
   cat "$@"
elif test "_$1_" = _x_
then
   shift
   count=0

   while read size name && test "_${size##[^0-9]}_" = "_${size}_"
   do
      sizes[count]=$((size))
      names[count]=${name}
      count=$((count+1))
   done

   if test "_${size}_" != "_-_"
   then
      echo "Bad dir"
      exit
   fi

   i=0
   while let 'i<count'
   do
      echo ${names[i]} ${sizes[i]}
      if test "_${names[i]##*/}_" != "_${names[i]}_"
      then
         install -d "${names[i]%/*}"
      fi
      dd bs=${sizes[i]} count=1 >"${names[i]}" 2>/dev/null
      i=$((i+1))
   done

else
   echo "To create an archive use: saf.sf c files..."
   echo "To extract an archive use: saf.sf x"
fi
There's the code. Save that as a saf.sf file, add the x bit to be able to run it in the terminal. Then:
saf.sf c file1 file2 file3 > file.saf