# this script does not work



## mfaridi (Jun 1, 2010)

I have this script 

```
#!/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
```
but when I run it with this command 

```
sh 4gb
```
I see this error

```
4gb: 1: Syntax error: word unexpected (expecting ")")
```
I test this script in Fedora and it work good


----------



## graudeejs (Jun 1, 2010)

No wonder
It's full of errors
http://www.grymoire.com/Unix/Sh.html


----------



## SirDice (Jun 1, 2010)

I use that site for reference quite often :e


----------



## DutchDaemon (Jun 1, 2010)

mfaridi said:
			
		

> I have this script
> 
> I test this script in Fedora and it work good



Linux's 'sh' = 'bash'. Either rewrite it in true sh syntax, or run it with 
	
	



```
#!/usr/local/bin/bash
```
.


----------

