Skip to content
Advertisement

Using bash, I want to print a number followed by sizes of 2 paths on one line. i.e. output of 3 commands on one line

Using bash, I want to print a number followed by sizes of 2 paths on one line. i.e. output of 3 commands on one line.

All the 3 items should be separated by “:”

JavaScript

I am getting the output as –

JavaScript

But I want the output as –

JavaScript

Advertisement

Answer

This should work for you. The two key elements added being the tr – d ‘n’ which effectively strips new line characters from the end of the output. As well as adding in the echo “:” to get the extra colon for formatting in there.

Hope this helps! Here’s a link to the docs for tr command. https://ss64.com/bash/tr.html

JavaScript
Advertisement