# Shell Script formatting broken due to whitespace trimming

**URL:** <https://community.folivora.ai/t/shell-script-formatting-broken-due-to-whitespace-trimming/32772>\
**Category:** Bugs or Unexpected Behavior\
**Tags:** widget\
**Created:** [August 15, 2023, 7:03pm UTC](https://community.folivora.ai/t/shell-script-formatting-broken-due-to-whitespace-trimming/32772 "2023-08-15T19:03:10Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Yury\_Ershov](https://community.folivora.ai/user_avatar/community.folivora.ai/yury_ershov/32/17703_2.png) [@Yury\_Ershov](https://community.folivora.ai/u/Yury_Ershov)\
**Post date:** [August 15, 2023, 7:36pm UTC](https://community.folivora.ai/t/shell-script-formatting-broken-due-to-whitespace-trimming/32772/4 "2023-08-15T19:36:48Z")

</div>

Yeah it's this one: [cpu top 2 (and top 30) (toolbar widget preset)](https://community.folivora.ai/t/cpu-top-2-and-top-30-toolbar-widget-preset/23890)

(note the screenshot from an earlier version)

The script being this:

```auto
ps -A -o %cpu,comm | perl -naE '
BEGIN{$n=$c=0};
chomp;
$n+=$F[0];
$c+=$F[0] if /Chrome\.app/;
$p = m{/([^/]+)\.app/} ? $1 : m{/([^/]+)$} ? $1 : m{^\s*[\d.]+\s++(.*)} ? $1 : $_;
$p{$p}+=$F[0];
END{
  print
    join "\n",
    map {sprintf "%16s %5.1f", substr($_,0,16), $p{$_}}
    (sort {$p{$b} <=> $p{$a}} keys %p)[0,1];
}
'

```

I think it might be because of some changes to 3rd party libraries where they attempt to center the line and automatically trim spaces when doing that.

---

_[View the full topic](https://community.folivora.ai/t/shell-script-formatting-broken-due-to-whitespace-trimming/32772)._
