D
D
DetRyg2022-03-26 20:05:40
linux
DetRyg, 2022-03-26 20:05:40

How can I display only file permissions using the cut command?

How can I use the cut command to display only file permissions on a long listing of a directory?
Let's take the /etc directory.
ls -l /etc
How can I redirect this to the cut command so that it only displays file permissions?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Kuts, 2022-03-26
@fox_12

After a minute of reading man cut:

$ ls -l /etc | cut -f 1 -d ' '

drwxr-xr-x
-rw-r--r--
-rw-r--r--
-rw-r--r--
-rw-r--r--
-r--r-----
drwxr-x---
-rw-r--r--
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
-rw-r--r--
...

X
xibir, 2022-03-26
@xibir

ls -l | cut -c1-10

K
ky0, 2022-03-26
@ky0

Why cut something right away when there is much more flexibility awk '{print $какой-там-у-вас-номер-поля}'?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question