I have this script
but when I run it with this command
I see this error
I test this script in Fedora and it work good
Code:
#!/bin/sh
CAP=4000000000
SIZEARR=(`ls -l |awk '{if(NR > 1) {print $5}}'`)
NAMEARR=(`ls -l |awk '{if(NR > 1) {print $8}}'`)
NUMELS=${#NAMEARR[@]}
NUMDIR=0
let N=$CAP+1
for (( i=0;i<$NUMELS;i++))
do
if [ $N -gt $CAP ]
then
let NUMDIR++
CURDIR="Dir$NUMDIR"
mkdir $CURDIR
let N=0
fi
let N=$N+${SIZEARR[${i}]}
cp ${NAMEARR[${i}]} $CURDIR
done
Code:
sh 4gb
Code:
4gb: 1: Syntax error: word unexpected (expecting ")")