GREP (Global regular expression print) là lệnh tìm kiếm các dòng có chứa một chuỗi hoặc từ khóa trong file. Trong bài viết này Hostvn sẽ hướng dẫn các bạn cách dùng lệnh grep cơ bản.
# grep ‘word’ filename
# grep ‘string1 string2′ filename
# cat otherfile | grep ‘something’
# command | grep ‘something’
# grep Port /etc/ssh/sshd_config
# grep -i port /etc/ssh/sshd_config ( sử dụng -i nếu bạn không nhớ chính xác là từ viết hoa hay không viết hoa )
# grep -c Port /etc/ssh/sshd_config
#grep -n Port /etc/ssh/sshd_config
# grep -v 22 /etc/ssh/sshd_config
# grep ^P /etc/ssh/sshd_config
# grep yes$ /etc/ssh/sshd_config
# cat /proc/cpuinfo |grep cpu