Skip to content

Guess the width (fwf) output without delimiters in commands that output to the terminal.

License

Notifications You must be signed in to change notification settings

noborus/guesswidth

Repository files navigation

guesswidth

Go Reference Go

ovewerview

guesswidth guesses the separator position in CLI output.

The output of the ps command has no delimiters, making the values difficult to machine-readable. guesswidth is smarter at guessing separators than just spaces.

install command

There is also a guesswidth command.

go install github.com/noborus/guesswidth/cmd/guesswidth@latest

Guess the width output with no delimiters in the command.

$ ps
    PID TTY          TIME CMD
 302965 pts/3    00:00:12 zsh
 733211 pts/3    00:00:00 ps
 733212 pts/3    00:00:00 tee
 733213 pts/3    00:00:00 guesswidth

Split the output like this:

$ ps | guesswidth
    PID| TTY     |     TIME|CMD
 302965| pts/3   | 00:00:08|zsh
 539529| pts/3   | 00:00:00|ps
 539530| pts/3   | 00:00:00|guesswidth

It can be converted to csv.

$ ps | guesswidth csv
PID,TTY,TIME,CMD
302965,pts/3,00:00:12,zsh
733211,pts/3,00:00:00,ps
733212,pts/3,00:00:00,tee
733213,pts/3,00:00:00,guesswidth

About

Guess the width (fwf) output without delimiters in commands that output to the terminal.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published