# Search string in multiple files and display column wise

**URL:** <https://community.unix.com/t/search-string-in-multiple-files-and-display-column-wise/369959>\
**Category:** Shell Programming and Scripting\
**Created:** [December 19, 2017, 10:29pm UTC](https://community.unix.com/t/search-string-in-multiple-files-and-display-column-wise/369959 "2017-12-19T22:29:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sidnow](https://community.unix.com/letter_avatar/sidnow/32/6_449c533f586939b6e5f246632a46421f.png) [@sidnow](https://community.unix.com/u/sidnow)\
**Post date:** [December 19, 2017, 10:29pm UTC](https://community.unix.com/t/search-string-in-multiple-files-and-display-column-wise/369959/1 "2017-12-19T22:29:19Z")

</div>

I have 3 files. Each of those files have the same number of records, however certain records have different values. I would like to grep the field in ALL 3 files and display the output with only the differences in column wise and if possible line number

```auto

File1

Name = Joe
Age = 33
Occupation = IT

File2

Name = Joe
Age = 33
Occupation = Doctor

File3

Name = Joe
Age = 33
Occupation = Engineer

```

So output after grepping for Occupation should look

```nohighlight

File 1 File 2 File3

Occupation = IT Occupation = Doctor Occupation = Engineer

```

---

<div class="post-metadata">

**Author:** ![RudiC](https://community.unix.com/letter_avatar/rudic/32/6_449c533f586939b6e5f246632a46421f.png) [@RudiC](https://community.unix.com/u/RudiC)\
**Post date:** [December 20, 2017, 4:05am UTC](https://community.unix.com/t/search-string-in-multiple-files-and-display-column-wise/369959/2 "2017-12-20T04:05:08Z")

</div>

Any attempts / ideas / thoughts from your side? Preferred tools?

---

<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:** [December 20, 2017, 11:41pm UTC](https://community.unix.com/t/search-string-in-multiple-files-and-display-column-wise/369959/3 "2017-12-20T23:41:22Z")

</div>

I also would love to see what you have tried to solve this problem on your own.

I think I have some code that does what you want, but I need to see that you've made an honest effort on your own before I post what I have...

---

<div class="post-metadata">

**Author:** ![drl](https://community.unix.com/user_avatar/community.unix.com/drl/32/542_2.png) [@drl](https://community.unix.com/u/drl)\
**Post date:** [December 23, 2017, 8:24am UTC](https://community.unix.com/t/search-string-in-multiple-files-and-display-column-wise/369959/4 "2017-12-23T08:24:18Z")

</div>

Hi.

> [@don cragun](#):
>
> ... I think I have some code that does what you want ...

Me too ... cheers, drl
