Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

ps has a nasty habit of truncating its output. Piping it into cat is a way around this. E.G.

  $ echo $COLUMNS
  118

  $ ps -fp 14706
  UID        PID  PPID  C STIME TTY          TIME CMD
  root     14706 14705  0 Jan29 pts/3    00:00:00 sudo -p [local sudo] Password:  python /usr/lib/sshuttle/main.py pytho

  $ ps -fp 14706 | cat
  UID        PID  PPID  C STIME TTY          TIME CMD
  root     14706 14705  0 Jan29 pts/3    00:00:00 sudo -p [local sudo] Password:  python /usr/lib/sshuttle/main.py python -v --firewall 12300 0


Most generally, it will trick any command into thinking that it's not writing to a tty ; so piping into cat will often remove colors.


Of course if you want colours, you can often force programs to use them anyway. For example, I use the alias:

  alias new='ls -lthr --color=always | tail'
Normally ls will not use colours when writing to a pipe (not a tty).


Using the -ww flag will produce unlimited width output


Thanks! I'd searched the ps manpage for truncate and length. I don't know why I didn't think to look for width.


"... Piping it into cat is a way around this. ..."

I've always preferred less - lets you scroll backwards & forwards through the piped output.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: