# File Processing

**URL:** <https://community.unix.com/t/file-processing/365819>\
**Category:** Shell Programming and Scripting\
**Created:** [March 28, 2017, 6:44am UTC](https://community.unix.com/t/file-processing/365819 "2017-03-28T06:44:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikhil\_jain](https://community.unix.com/letter_avatar/nikhil_jain/32/6_449c533f586939b6e5f246632a46421f.png) [@nikhil\_jain](https://community.unix.com/u/nikhil_jain)\
**Post date:** [March 28, 2017, 6:44am UTC](https://community.unix.com/t/file-processing/365819/1 "2017-03-28T06:44:00Z")

</div>

Hi ALL,

I have below file generated as o/p after my java code runs,

```nohighlight
Student Id 22552530 Below is the size
(22ms, 835 bytes
Student Id 2124592 Below is the size
(55ms, 703 bytes
Student Id 23903104 Below is the size
(46ms, 24333 bytes
Student Id 23903104 Below is the size
(61ms, 24333 bytes
Student Id 23903104 Below is the size
(8ms, 24333 bytes
Student Id 23903104 Below is the size
(129ms, 24333 bytes
Student Id 21246414 Below is the size
(133ms, 28601 bytes
Student Id 23906410 Below is the size
(21ms, 1520 bytes

```

[/CODE]

I wanted all the Student id's whose size exceeds 1000 bytes

---

<div class="post-metadata">

**Author:** ![RavinderSingh13](https://community.unix.com/letter_avatar/ravindersingh13/32/6_449c533f586939b6e5f246632a46421f.png) [@RavinderSingh13](https://community.unix.com/u/RavinderSingh13)\
**Post date:** [March 28, 2017, 7:12am UTC](https://community.unix.com/t/file-processing/365819/2 "2017-03-28T07:12:25Z")

</div>

Hello nikhil jain,

If you want duplicates into your answer then following may help you in same.

```nohighlight
awk '/Student/{A=$0;next} /bytes/ && A && $2 > 1000{print A;A=""}' Input_file

```

If you don't want to get duplicates then following may help you in same.

```nohighlight
awk '/Student/{B=$3;A=$0;!C++;next} /bytes/ && C==1 && $2 > 1000{print A}' Input_file

```

Thanks,  
R. Singh

---

<div class="post-metadata">

**Author:** ![nikhil\_jain](https://community.unix.com/letter_avatar/nikhil_jain/32/6_449c533f586939b6e5f246632a46421f.png) [@nikhil\_jain](https://community.unix.com/u/nikhil_jain)\
**Post date:** [March 29, 2017, 3:32am UTC](https://community.unix.com/t/file-processing/365819/3 "2017-03-29T03:32:23Z")

</div>

Hi Ravinder

Thanks a lot 🙂 It did worked.

---------- Post updated 03-29-17 at 01:02 PM ---------- Previous update was 03-28-17 at 05:04 PM ----------

```nohighlight
awk '/Student/{B=$3;A=$0;!C++;next} /bytes/ && C==1 && A=0{print A}' Input_file

```

The above code does not work, if i want to find the size with 0 bytes. Can anyone please look into it and make the code correct.

---

<div class="post-metadata">

**Author:** ![RavinderSingh13](https://community.unix.com/letter_avatar/ravindersingh13/32/6_449c533f586939b6e5f246632a46421f.png) [@RavinderSingh13](https://community.unix.com/u/RavinderSingh13)\
**Post date:** [March 29, 2017, 3:37am UTC](https://community.unix.com/t/file-processing/365819/4 "2017-03-29T03:37:32Z")

</div>

Hello nikhil jain,

You are using assignment operator, it should be as follows.

```nohighlight
awk '/Student/{B=$3;A=$0;!C++;next} /bytes/ && C==1 && $2==0{print A}' Input_file

```

Thanks,  
R. Singh
