Hamid's blog

Linux Hints: 3. use "vipe" to edit pipe data while passing on

May 17, 2020

shell command:

    ps -f -u ${USER} | vipe | wc -l

** What does it do?**

Does full-format listing of processes of current user. Pipes it to "vipe" command that gives the user a chance to modify it on the fly, and then does a line count "wc -l" on it.


description:

  • ps -f -u ${USER}

    • ps A command to report a snapshot of the current processes
    • -f full-format listing output format (shows useful information in output of the command)
    • -u ${USER} show processes for current user

  • |

    • linux pipe to pass output of ps to next command

  • vipe

    • vipe command allows you to run your editor in the middle of a unix pipeline and edit the data that is being piped between programs
    • See "man vipe"
    • To install vipe command on Ubuntu 20.04: sudo apt install moreutils
    • vipe opens the default editor in cli. On Ubuntu 20.04 default cli editor is nano. One way of changing it, and using vi instead, is adding export EDITOR=vi to ~/.bashrc, using following command:

          echo "export EDITOR=vi" >> ~/.bashrc
      

  • wc -l

    • wc is a word count command
    • -l causes it to show only line-count in output