# script error.. help me

**URL:** <https://community.unix.com/t/script-error-help-me/238024>\
**Category:** Shell Programming and Scripting\
**Created:** [April 18, 2009, 5:13am UTC](https://community.unix.com/t/script-error-help-me/238024 "2009-04-18T05:13:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![topic32428285](https://community.unix.com/letter_avatar/topic32428285/32/6_449c533f586939b6e5f246632a46421f.png) [@topic32428285](https://community.unix.com/u/topic32428285)\
**Post date:** [April 18, 2009, 5:13am UTC](https://community.unix.com/t/script-error-help-me/238024/1 "2009-04-18T05:13:25Z")

</div>

#!/bin/ksh  
while read line  
do  
cd $line/radmin  
num=0  
for file\_nm in \*.txt  
do

```
\(\( check = $RANDOM % 2 \)\)

if [$check -eq 0]; then
  continue
fi

\(\( num = num \+ 1 \)\)

echo /bin/cp $PWD/$file_nm $PWD/newword$\{num\}.word

if [$num -ge 6]; then
  break
fi

```

done ### while doing random renaming....

done \< source.txt

all newwordX.word not be created..  
plz check it..  
thanks

---

<div class="post-metadata">

**Author:** ![zedex](https://community.unix.com/letter_avatar/zedex/32/6_449c533f586939b6e5f246632a46421f.png) [@zedex](https://community.unix.com/u/zedex)\
**Post date:** [April 18, 2009, 7:08am UTC](https://community.unix.com/t/script-error-help-me/238024/2 "2009-04-18T07:08:30Z")

</div>

first of all use CODE tags while posting your code

```nohighlight
#!/bin/ksh
while read line
do
    cd $line/radmin
    num=0
    # /bin/ls *.txt | - you are trying list all the TXT files 
    # for file_nm in *.txt
    for file_nm in *.txt
    do 
       check=$(( $RANDOM % 2 ))
       if [$check -eq 0]; then
          continue
       fi
       # (( num = num + 1 ))
       num = $(( $num + 1 ))
       echo /bin/mv $PWD/$file_nm $PWD/t_level${num}.words
       if [$num -ge 6]; then
            break
       fi
    done
done < source.txt

```

---

<div class="post-metadata">

**Author:** ![topic32428285](https://community.unix.com/letter_avatar/topic32428285/32/6_449c533f586939b6e5f246632a46421f.png) [@topic32428285](https://community.unix.com/u/topic32428285)\
**Post date:** [April 18, 2009, 7:58am UTC](https://community.unix.com/t/script-error-help-me/238024/3 "2009-04-18T07:58:01Z")

</div>

deleted
