3

I was running a pipe command with one section being the following:

sort -t $'\t'  -T . -k1,1g

When I was monitoring htop I saw this instead:

enter image description here

What is the reason behind this? Does this mean my command is wrong or is there something wrong with htop?

2
  • 4
    Important to remember that the command line that htop retrieved from procfs and is displaying doesn't contain the (shell-specific) four-character $'\t' sequence but instead just a 1-character tab literal that the shell parsed that sequence into. Jan 16 at 23:35
  • 1
    (And unlike bash, POSIX sh doesn't have any way to write a tab with only printable characters, so there isn't really a good portable rendering available) Jan 16 at 23:40

2 Answers 2

13

There’s nothing wrong with your command, htop replaces control characters with question marks:

(((unsigned char)data_c[j]) >= 32 ? ((unsigned char)data_c[j]) : '?')

(characters with values less than 32 are control characters).

1

The htop process manager displays $'\t' as ? in the sort command because it interprets the \t as a tab character, which is not a valid sorting option.

In the sort command, \t is used as a delimiter to specify the field that the command should sort by. However, in htop, it is not a valid delimiter and is therefore displayed as ? in the sort column.

You can try to use the -k option to specify the sort field and the -t option to specify the delimiter. For example, htop -u -p -k 2,2 -t ' ' sorts by the 2nd field using a space as a delimiter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.