i have problem with sorting in variable.
I work with Bash and with NSH console.
I load to variable, biggest folders in my OS:
vdirList=$(nexec -e "find /etc -type d -size +1k -print0 | xargs -0 du -h --max-depth 3 --time --time-style +'%F %T %z' 2>/dev/null| sort -h -k1 2>/dev/null| tail -7 | sed -n '$ ! p' | uniq -c | tac | sed 's/^/BAORES: /'") vdirList+="\n" vdirList+=$(nexec -e "find /usr -type d -size +1k -print0 | xargs -0 du -h --max-depth 3 --time --time-style +'%F %T %z' 2>/dev/null| sort -h -k1 2>/dev/null| tail -7 | sed -n '$ ! p' | uniq -c | tac | sed 's/^/BAORES: /'") vdirList+="\n" This is output:
BAORES: 3 22M 2017-05-05 14:53:20 +0300 /etc/selinux/targeted BAORES: 2 22M 2017-05-05 14:53:20 +0300 /etc/selinux BAORES: 1 13M 2017-05-05 14:53:20 +0300 /etc/selinux/targeted/modules BAORES: 2 1.9G 2018-12-20 05:49:04 +0200 /usr/lib BAORES: 3 1.3G 2018-12-20 05:48:55 +0200 /usr/lib/x86_64-linux-gnu BAORES: 1 445M 2018-12-20 05:49:04 +0200 /usr/lib/i386-linux-gnu I want sort this files by 3 column i use this command:
dirList=$(nexec -e "echo \"$vdirList\" | sort -hrk3 | head -n 10") But my output is:
BAORES: 3 22M 2017-05-05 14:53:20 +0300 /etc/selinux/targeted BAORES: 3 1.3G 2018-12-20 05:48:55 +0200 /usr/lib/x86_64-linux-gnu BAORES: 2 22M 2017-05-05 14:53:20 +0300 /etc/selinux BAORES: 1 445M 2018-12-20 05:49:04 +0200 /usr/lib/i386-linux-gnu BAORES: 1 13M 2017-05-05 14:53:20 +0300 /etc/selinux/targeted/modules BAORES: 2 1.9G 2018-12-20 05:49:04 +0200 /usr/lib Can someone help with this? Thanks.