cut

How to cut lines separated by multiple spaces?

Here is an example of cut command, that will remove all PHP packages from system

dpkg -l | grep php | cut -d" " -f3 | xargs apt purge -y 

Get user names

cut -d':' -f1 /etc/passwd

Display users with SSH enabled

grep "/bin/bash" /etc/passwd | cut -d':' -f1,6

List all IPs that have accessed admin area from Apache Log

cat LOG_FILE_NAME_HERE | grep '/admin/' |  cut -d' ' -f1 | sort -n | uniq

See Linux Commands

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *