Algo que resulta util cuando se quiere filtrar la salida de un comando que maneja columas es utilizar awk.
imaginemos que necesitamos filtrar la salida del comando ls -lrta que de forma normal se ve asi:
DESKTOP-BRCUETC% ls -lrta
total 2060
drwxr-xr-x 1 root root 4096 Apr 18 2022 boot
lrwxrwxrwx 1 root root 7 Nov 22 15:36 bin -> usr/bin
lrwxrwxrwx 1 root root 8 Nov 22 15:36 sbin -> usr/sbin
lrwxrwxrwx 1 root root 10 Nov 22 15:36 libx32 -> usr/libx32
lrwxrwxrwx 1 root root 9 Nov 22 15:36 lib64 -> usr/lib64
lrwxrwxrwx 1 root root 9 Nov 22 15:36 lib32 -> usr/lib32
lrwxrwxrwx 1 root root 7 Nov 22 15:36 lib -> usr/lib
drwxr-xr-x 1 root root 4096 Nov 22 15:36 srv
drwxr-xr-x 1 root root 4096 Nov 22 15:36 opt
drwxr-xr-x 1 root root 4096 Nov 22 15:36 media
drwxr-xr-x 1 root root 4096 Nov 22 15:36 usr
drwxr-xr-x 1 root root 4096 Nov 22 15:37 var
drwxr-xr-x 1 root root 4096 Nov 22 15:37 snap
-rwxr-xr-x 2 root root 2105816 Dec 1 08:34 init
drwxr-xr-x 1 root root 4096 Jan 22 23:47 ..
drwxr-xr-x 1 root root 4096 Jan 22 23:47 .
drwxr-xr-x 1 root root 4096 Jan 22 23:48 home
drwx------ 1 root root 4096 Jan 22 23:52 root
drwxr-xr-x 1 root root 4096 Jan 23 00:25 mnt
dr-xr-xr-x 12 root root 0 Jan 24 22:22 sys
dr-xr-xr-x 10 root root 0 Jan 24 22:22 proc
drwxr-xr-x 1 root root 4096 Jan 24 22:31 dev
drwxr-xr-x 1 root root 4096 Jan 24 22:36 run
drwxrwxrwt 1 root root 4096 Jan 24 22:36 tmp
drwxr-xr-x 1 root root 4096 Jan 24 22:38 etc
si quisieramos obtener solo las columnas de propietario, grupo y nombre del archivo/directorio, podriamos utilizar el siguiente comando:
ls -lrta | awk ‘{print $3, $4, $9}’
que nos daria una stdout de este estilo:
DESKTOP-BRCUETC% ls -lrta | awk ‘{print $3, $4, $9}’
root root boot
root root bin
root root sbin
root root libx32
root root lib64
root root lib32
root root lib
root root srv
root root opt
root root media
root root usr
root root var
root root snap
Espero sea de ayuda.
@cesarvyepez