# string processing

**URL:** <https://community.unix.com/t/string-processing/236053>\
**Category:** Shell Programming and Scripting\
**Created:** [March 24, 2009, 6:56am UTC](https://community.unix.com/t/string-processing/236053 "2009-03-24T06:56:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Satyak](https://community.unix.com/letter_avatar/satyak/32/5_5575768a8748004e209b776fc1b2916d.png) [@Satyak](https://community.unix.com/u/Satyak)\
**Post date:** [March 24, 2009, 6:56am UTC](https://community.unix.com/t/string-processing/236053/1 "2009-03-24T06:56:16Z")

</div>

hi,

I have a string "satabeltodounixscriptingpleasecheckfortheerros"

in the above line if it contains "unix" , i need to take 5 characters after that word.

please help

thanks in advance  
Satya

---

<div class="post-metadata">

**Author:** ![Shahul](https://community.unix.com/user_avatar/community.unix.com/shahul/32/1043_2.png) [@Shahul](https://community.unix.com/u/Shahul)\
**Post date:** [March 24, 2009, 7:15am UTC](https://community.unix.com/t/string-processing/236053/2 "2009-03-24T07:15:01Z")

</div>

```nohighlight
 $ echo "satabeltodounixscriptingpleasecheckfortheerros" |sed 's/.*unix//g'|awk '{print substr($0,1,6)}'

script

```

Thanks  
Sha

---

<div class="post-metadata">

**Author:** ![ghostdog74](https://community.unix.com/letter_avatar/ghostdog74/32/5_5575768a8748004e209b776fc1b2916d.png) [@ghostdog74](https://community.unix.com/u/ghostdog74)\
**Post date:** [March 24, 2009, 7:18am UTC](https://community.unix.com/t/string-processing/236053/3 "2009-03-24T07:18:46Z")

</div>

no need for that extra awk process

```nohighlight
echo "satabeltodounixscriptingpleasecheckfortheerros" |sed 's/.*unix\(.....\).*/\1/'

```
