Afficher les fichiers ou dossier qui se terminent par .conf ou .d
[root@centos etc]# ls /etc/ | grep -E '(.conf|.d)$'
Bonus
Recherche chaine de caractère dans un des fichiers d'un répertoire courant:
linux# grep chaine *
Exemple:
linux:/etc/init.d# grep hostname * bootmisc.sh:# Required-Start: hostname $remote_fs checkroot.sh:# Required-Start: mountdevsubfs hostname hostname.sh:# Provides: hostname hostname.sh:# Short-Description: Set hostname based on /etc/hostname hostname.sh:# Description: Read the machines hostname from /etc/hostname, and hostname.sh:# /etc/hostname is empty, the current kernel value hostname.sh:# for hostname is used. If the kernel value is hostname.sh: [ -f /etc/hostname ] && HOSTNAME="$(cat /etc/hostname)" hostname.sh: # Keep current name if /etc/hostname is missing. hostname.sh: [ -z "$HOSTNAME" ] && HOSTNAME="$(hostname)" hostname.sh: [ "$VERBOSE" != no ] && log_action_begin_msg "Setting hostname to '$HOSTNAME'" hostname.sh: hostname "$HOSTNAME" hostname.sh: echo "Usage: hostname.sh [start|stop]" >&2
Afficher le ou les numéros de lignes ou se trouve l'expression recherchée
grep -n "expression" nomdufichier
Aucun commentaire:
Enregistrer un commentaire