# Remove Data from Fields

**URL:** <https://community.unix.com/t/remove-data-from-fields/168285>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [January 14, 2007, 1:17pm UTC](https://community.unix.com/t/remove-data-from-fields/168285 "2007-01-14T13:17:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![greengrass](https://community.unix.com/letter_avatar/greengrass/32/6_22734026db12803ebb3e059622ac3534.png) [@greengrass](https://community.unix.com/u/greengrass)\
**Post date:** [January 14, 2007, 1:17pm UTC](https://community.unix.com/t/remove-data-from-fields/168285/1 "2007-01-14T13:17:45Z")

</div>

I would like some sugestions on how to solve the following problem with removing selected data from fields. Each day I receive a file containing 22,000 records that I use a combination of awk and the cut command to remove unwanted fields. This is a work in process as I learn more about awk, sed and other tools.

The problem I am struggling with is how can i remove only the time stamp, days, day from the last field? I only want the number days in the last field. For days less than 1 if I can place a "0" in field great, I think a blank will work for now.

Below is a sample of the file output.  
Thanks

|1|8|0|0|10 days, 5:35:33  
|1|8|0|0|0:00:00  
|1|8|0|0|18 days, 12:08:44  
|1|8|0|0|0:09:25  
|1|8|0|0|23:59:25  
|1|8|0|0|1 day, 1:16:25

---

<div class="post-metadata">

**Author:** ![Mark\_Thomas](https://community.unix.com/letter_avatar/mark_thomas/32/6_22734026db12803ebb3e059622ac3534.png) [@Mark\_Thomas](https://community.unix.com/u/Mark_Thomas)\
**Post date:** [January 14, 2007, 1:28pm UTC](https://community.unix.com/t/remove-data-from-fields/168285/2 "2007-01-14T13:28:50Z")

</div>

Can you show how you want to output to look? I'm not sure I understand what it is exactly you want removed.

---

<div class="post-metadata">

**Author:** ![greengrass](https://community.unix.com/letter_avatar/greengrass/32/6_22734026db12803ebb3e059622ac3534.png) [@greengrass](https://community.unix.com/u/greengrass)\
**Post date:** [January 14, 2007, 1:53pm UTC](https://community.unix.com/t/remove-data-from-fields/168285/3 "2007-01-14T13:53:10Z")

</div>

I hope this helps.

BEFORE  
|1|8|0|0|10 days, 5:35:33  
|1|8|0|0|0:00:00  
|1|8|0|0|18 days, 12:08:44  
|1|8|0|0|0:09:25  
|1|8|0|0|23:59:25  
|1|8|0|0|1 day, 1:16:25

AFTER  
|1|8|0|0|10  
|1|8|0|0|0 If \<24 hours = 1 or 0  
|1|8|0|0|18  
|1|8|0|0|0 If \<24 hours = 1 or 0  
|1|8|0|0|0 If \<24 hours = 1 or 0  
|1|8|0|0|1

---

<div class="post-metadata">

**Author:** ![Perderabo](https://community.unix.com/user_avatar/community.unix.com/perderabo/32/27_2.png) [@Perderabo](https://community.unix.com/u/Perderabo)\
**Post date:** [January 14, 2007, 3:58pm UTC](https://community.unix.com/t/remove-data-from-fields/168285/4 "2007-01-14T15:58:47Z")

</div>

Try:  
sed 's/day.\*//g;s/[0-9]\*:[0-9]\*:[0-9]\*$/0/'

---

<div class="post-metadata">

**Author:** ![greengrass](https://community.unix.com/letter_avatar/greengrass/32/6_22734026db12803ebb3e059622ac3534.png) [@greengrass](https://community.unix.com/u/greengrass)\
**Post date:** [January 15, 2007, 4:41pm UTC](https://community.unix.com/t/remove-data-from-fields/168285/5 "2007-01-15T16:41:46Z")

</div>

Perderabo,

Thank you, this worked great!
