3 Basic Commands and Simple Shell Scripts Once you have your first Red Hat Enterprise Linux rhel



Download 1.85 Mb.
View original pdf
Page18/67
Date26.02.2024
Size1.85 Mb.
#63678
1   ...   14   15   16   17   18   19   20   21   ...   67
Pablo Iranzo Gómez, Pedro Ibáñez Requena, Miguel Pérez Colino, Scott McCarty - Red Hat Enterprise Linux 9 Administration-Packt Publishing (2022) -chap 3 82 - 180
[root@rhel-instance
]# ls -l

total 1888
-rw-------. 1 root root 1393 Feb 18 19:45 anaconda-ks.cfg
-rw-r--r--. 1 root root 52 Feb 16 12:17 error.txt
-rw-r--r--. 1 root root 0 Feb 16 12:08 non-listing.txt
-rw-r--r--. 1 root root 1917837 Feb 16 12:40 usr-files.txt
-rw-r--r--. 1 root root 360 Feb 16 12:12 var-files.txt
Let’s say we only want the size, which is the fifth column, of the content that has files in its name. We can use awk for that:
[root@rhel-instance
]# ls -l | grep files | awk '{ print $5}'

1917837
360
The awk tool will help us to filter according to the correct column. It is very useful for finding identifiers in processes or forgetting a specific list of data from along output.
Tip
Consider that awk is super powerful for processing output and that we will use the minimal capability for it.
We could replace the separator with -F and get a list of available users in the system:
[root@rhel-instance
]# awk -F '{ print $1}' /etc/passwd

root
bin

Listing, creating, copying, and moving files, directories, links, and hard links
83
daemon
adm
lp
sync
shutdown
halt
mail
operator
games
ftp
nobody
dbus
systemd-coredump
systemd-resolve
tss
polkitd
unbound
sssd
chrony
sshd
rngd
user
The awk and grep tools are very common processing tools in the life of a Linux sysadmin, and it is important to understand them well to manage the output provided by the system. We have applied the base knowledge to filter the output received by row and column. Let’s now move onto how to manage files in a system so that we can better handle the stored output we have just generated.

Download 1.85 Mb.

Share with your friends:
1   ...   14   15   16   17   18   19   20   21   ...   67




The database is protected by copyright ©ininet.org 2024
send message

    Main page