# Problem with a code.

**URL:** <https://community.unix.com/t/problem-with-a-code/361719>\
**Category:** Shell Programming and Scripting\
**Created:** [July 30, 2016, 1:53am UTC](https://community.unix.com/t/problem-with-a-code/361719 "2016-07-30T01:53:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nirjhar17](https://community.unix.com/letter_avatar/nirjhar17/32/5_5575768a8748004e209b776fc1b2916d.png) [@nirjhar17](https://community.unix.com/u/nirjhar17)\
**Post date:** [July 30, 2016, 1:53am UTC](https://community.unix.com/t/problem-with-a-code/361719/1 "2016-07-30T01:53:12Z")

</div>

Guys i have one file and i want the o/p from that file like below

This is my sample file and i want three things from it.

Name:  
State just below the Name: dont want the state under the Retention Level:  
And retention Level

```nohighlight
  Name: MEANS_SLP_DAILY
                               State: inactive
                     Retention Level: 3 (1 month)
                               State: active
                     Retention Level: 3 (1 month)
                               State: active
                     Retention Level: 3 (1 month)
                               State: active
                                Name: MEANS_SLP_WEEKLY
                               State: inactive
                     Retention Level: 3 (1 month)
                               State: active
                     Retention Level: 3 (1 month)
                               State: active
                     Retention Level: 3 (1 month)
                               State: active
                                Name: SLP_Irv_Arlington_Test
                               State: active
                     Retention Level: 1 (2 weeks)
                               State: active
                     Retention Level: 1 (2 weeks)
                               State: active
                     Retention Level: 1 (2 weeks)
                               State: active 

```

I have tried this code for the above file but here i am not getting retention level. I also want to grep retention level too. Please suggest

```nohighlight
 cat /tmp/1 | grep 'Name' -A1
                                Name: MEANS_SLP_DAILY
                               State: inactive
--
                                Name: MEANS_SLP_WEEKLY
                               State: inactive
--
                                Name: SLP_Irv_Arlington_Test
                               State: active

```

I want my final o/p look like below

```nohighlight
Name: MEANS_SLP_DAILY State: inactive Retention Level: 3 (1 month) Retention Level: 3 (1 month) Retention Level: 3 (1 month)
Name: MEANS_SLP_Weekly State: inactive Retention Level: 3 (1 month) Retention Level: 3 (1 month) Retention Level: 3 (1 month)
   
 

```

---

<div class="post-metadata">

**Author:** ![Don\_Cragun](https://community.unix.com/user_avatar/community.unix.com/don_cragun/32/2682_2.png) [@Don\_Cragun](https://community.unix.com/u/Don_Cragun)\
**Post date:** [July 30, 2016, 2:20am UTC](https://community.unix.com/t/problem-with-a-code/361719/2 "2016-07-30T02:20:39Z")

</div>

Moderator comments were removed during original forum migration.
