Making the best CLI programs - Programming On Unix
Users browsing this thread: 6 Guest(s)
|
|||
(01-06-2016, 10:40 AM)sshbio Wrote: This would be just as easy (or even easier) by adding a header and with alignment, like for ps: I'm not quite sure. To be honest, I feel like headers/alignment makes it harder to parse the output. For example, in order to get all the temperature, you'll need: Code: $ weather | sed 1d | tr -s ' ' | cut -d\ -f5 You first need to filter out the header, then, get rid of the alignment, and finally output the 5 field, using a custom separator. With my solution, all you need is Code: $ weather | cut -f5 Way easier to parse actually, and thus, it should be easy to make a "readable output" right? Code: $ weather | sed '1iCity\tWind\tHumidity\tRain\tTemperature' | column -t |
|||