Re: saf extractor
Posted: Tue Oct 08, 2013 1:31 am
MX PRODIGY 17 wrote:It's funny cause it's JLV
MX PRODIGY 17 wrote:It's funny cause it's JLV
jlv wrote:Here you go:
Code: Select all
#!/bin/bash # # Simple Archive Format # #set -C if test "_$1_" = _c_ then shift find "$@" -maxdepth 0 -printf '%s %p\n' 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
jlv wrote:If you don't use Linux then FU!
Ooooh no Unix love.. just Linux..?wheels1758 wrote:jlv wrote:If you don't use Linux then FU!
You have the code on page 1, why would you need a link?ty casey wrote:someone shoot me a link.
jlv wrote:Here you go:
[code]#!/bin/bash
#
# Simple Archive Format
#
#set -C
if test "_$1_" = _c_
then
shift
find "$@" -maxdepth 0 -printf '%s %p\n'
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} ${sizes}
if test "_${names##*/}_" != "_${names}_"
then
install -d "${names%/*}"
fi
dd bs=${sizes} count=1 >"${names}" 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
[/code]
Thanks! That worked. I though the new line after "./saf.sf x" was enough to insert "NewTreespack.saf" on, but apparently it wasn't. Thanks again!jlv wrote:You have to redirect the saf as the standard input:
./saf.sf x <NewTreespack.saf
Without the redirect op < it should have just hung waiting for input until you pressed ctrl-c or ctrl-d.