# Linux Script help

**URL:** <https://community.unix.com/t/linux-script-help/193142>\
**Category:** Shell Programming and Scripting\
**Created:** [April 15, 2008, 9:28am UTC](https://community.unix.com/t/linux-script-help/193142 "2008-04-15T09:28:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dastard](https://community.unix.com/letter_avatar/dastard/32/5_5575768a8748004e209b776fc1b2916d.png) [@Dastard](https://community.unix.com/u/Dastard)\
**Post date:** [April 15, 2008, 9:28am UTC](https://community.unix.com/t/linux-script-help/193142/1 "2008-04-15T09:28:44Z")

</div>

Hi Everyone , have a nice day  
given below is a simple linux script  
but its first part is not working ( variable k assignment ) , while second loop is working fine  
can anyone help me out with this

```auto
#!/bin/sh
echo "Enter Date"
read date1
for i in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
do
k = `grep -i success /var/seamless/spool/tdr/ERS_200804$date1$i* | wc -l`
echo $k
done
echo " "
for i in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
do
grep -i fail /var/seamless/spool/tdr/ERS_200804$date1$i* | wc -l
done

```

Thanks in Anticipation

---

<div class="post-metadata">

**Author:** ![aahhhchoooo](https://community.unix.com/letter_avatar/aahhhchoooo/32/5_5575768a8748004e209b776fc1b2916d.png) [@aahhhchoooo](https://community.unix.com/u/aahhhchoooo)\
**Post date:** [April 15, 2008, 9:43am UTC](https://community.unix.com/t/linux-script-help/193142/2 "2008-04-15T09:43:59Z")

</div>

> [@dastard](#):
>
> Hi Everyone , have a nice day  
> given below is a simple linux script  
> but its first part is not working ( variable k assignment ) , while second loop is working fine  
> can anyone help me out with this
> 
> ```html
> #!/bin/sh
> echo "Enter Date"
> read date1
> for i in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
> do
> k = `grep -i success /var/seamless/spool/tdr/ERS_200804$date1$i* | wc -l`
> echo $k
> done
> echo " "
> for i in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
> do
> grep -i fail /var/seamless/spool/tdr/ERS_200804$date1$i* | wc -l
> done
> 
> ```
> 
> Thanks in Anticipation

Remove the spaces surrounding the = when you assign the variable k. It should read  
k=`grep -i....`

Remember you can put a "-x" at the end of your #!/bin/sh statement and it will run the script in debug

---

<div class="post-metadata">

**Author:** ![Dastard](https://community.unix.com/letter_avatar/dastard/32/5_5575768a8748004e209b776fc1b2916d.png) [@Dastard](https://community.unix.com/u/Dastard)\
**Post date:** [April 15, 2008, 12:10pm UTC](https://community.unix.com/t/linux-script-help/193142/3 "2008-04-15T12:10:24Z")

</div>

```
k =`grep -i success /var/seamless/spool/tdr/ERS_200804$date1$i* | wc -l`
echo $k
done

```

i have added -x for debug , not it is calculating value of k , but its not echoing it , what could possibly be wrong with echo $k  
☹

---

<div class="post-metadata">

**Author:** ![DukeNuke2](https://community.unix.com/user_avatar/community.unix.com/dukenuke2/32/407_2.png) [@DukeNuke2](https://community.unix.com/u/DukeNuke2)\
**Post date:** [April 15, 2008, 12:44pm UTC](https://community.unix.com/t/linux-script-help/193142/4 "2008-04-15T12:44:00Z")

</div>

> [@dastard](#):
>
> ```html
> k =`grep -i success /var/seamless/spool/tdr/ERS_200804$date1$i* | wc -l`
> echo $k
> done
> 
> ```
> 
> i have added -x for debug , not it is calculating value of k , but its not echoing it , what could possibly be wrong with echo $k  
> ☹

remove the space as allready suggested before...

```plaintext
k=`your code`

```

---

<div class="post-metadata">

**Author:** ![Dastard](https://community.unix.com/letter_avatar/dastard/32/5_5575768a8748004e209b776fc1b2916d.png) [@Dastard](https://community.unix.com/u/Dastard)\
**Post date:** [April 15, 2008, 12:47pm UTC](https://community.unix.com/t/linux-script-help/193142/5 "2008-04-15T12:47:12Z")

</div>

Worked :D:D  
Thanks a bunch

---

<div class="post-metadata">

**Author:** ![xNaTe128x](https://community.unix.com/letter_avatar/xnate128x/32/5_5575768a8748004e209b776fc1b2916d.png) [@xNaTe128x](https://community.unix.com/u/xNaTe128x)\
**Post date:** [April 15, 2008, 7:57pm UTC](https://community.unix.com/t/linux-script-help/193142/6 "2008-04-15T19:57:17Z")

</div>

Do you know how to make up the script "cp file1 file2"? If you don't know, do you know of anyone else that could help me? I need a response as soon as possible, I greatly appreciate any help you can give me.

---

<div class="post-metadata">

**Author:** ![vgersh99](https://community.unix.com/user_avatar/community.unix.com/vgersh99/32/14851_2.png) [@vgersh99](https://community.unix.com/u/vgersh99)\
**Post date:** [April 15, 2008, 8:12pm UTC](https://community.unix.com/t/linux-script-help/193142/7 "2008-04-15T20:12:05Z")

</div>

> [@xnate128x](#):
>
> Do you know how to make up the script "cp file1 file2"? If you don't know, do you know of anyone else that could help me? I need a response as soon as possible, I greatly appreciate any help you can give me.

Pls don't 'hijack' other people's threads - start a new thread.  
Read the [Rules](http://www.unix.com/unix-dummies-questions-answers/2971-simple-rules-unix-com-forums.html) of these forums FIRST.
