#!/bin/bash FILE=$1 # Get size of file and current offset SIZE=$(stat --printf="%s" $FILE) OFFSET=$(cat ./fs/offset) # Write file into block dd if=$1 of="./fs/0.block" seek=$OFFSET oflag=seek_bytes RESULT=$? if [[ "$RESULT" == "0" ]]; then # Append index and update offset echo "$FILE;$OFFSET;$SIZE" >> ./fs/fileIndex echo $((( $OFFSET + $SIZE ))) > ./fs/offset echo "file inserted" fi;