LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how do I grep for a key phrase (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-grep-for-a-key-phrase-4175574979/)

BW-userx 03-15-2016 01:52 PM

how do I grep for a key phrase
 
I am working on getting my terminal prompt to change to [root@host]#

when ever I log in su in a terminal then next step keep it in bash so I can use the arrow keys. I've ran into some trouble.

Now I am looking for a file containing a phrase within it so I can know where it is at so I can know what file is causing a disturbance within my system.

Code:

grep PS1='[\u@\h rooty \W]\$ ' /etc/*
or the whole dang system for all that matters until I find that file that contains that phrase within it.

even stripping it down to
Code:

grep "rooty" path to look in
because this is the results of [userx@voided rooty ~]$ grep "rooty" /etc/*
Code:

[userx@voided rooty ~]$ grep "rooty"  /etc/*
grep: /etc/ConsoleKit: Is a directory
grep: /etc/NetworkManager: Is a directory
grep: /etc/UPower: Is a directory
grep: /etc/X11: Is a directory
grep: /etc/acpi: Is a directory
grep: /etc/at-spi2: Is a directory
grep: /etc/bash: Is a directory
grep: /etc/ca-certificates: Is a directory
grep: /etc/colors: Is a directory
grep: /etc/cron.daily: Is a directory
grep: /etc/cups: Is a directory
grep: /etc/dbus-1: Is a directory
grep: /etc/default: Is a directory
grep: /etc/depmod.d: Is a directory
grep: /etc/dkms: Is a directory
grep: /etc/dns: Is a directory
grep: /etc/dracut.conf.d: Is a directory
grep: /etc/fonts: Is a directory
grep: /etc/gconf: Is a directory
grep: /etc/gimp: Is a directory
grep: /etc/group-: Permission denied
grep: /etc/grub.d: Is a directory
grep: /etc/gshadow: Permission denied
grep: /etc/gshadow-: Permission denied
grep: /etc/gtk-2.0: Is a directory
grep: /etc/gtk-3.0: Is a directory
grep: /etc/i3: Is a directory
grep: /etc/iproute2: Is a directory
grep: /etc/kernel.d: Is a directory
grep: /etc/ld.so.conf.d: Is a directory
grep: /etc/libnl: Is a directory
grep: /etc/libpaper.d: Is a directory
grep: /etc/logrotate.d: Is a directory
grep: /etc/lvm: Is a directory
grep: /etc/lxdm: Is a directory
grep: /etc/modprobe.d: Is a directory
grep: /etc/mplayer: Is a directory
grep: /etc/openldap: Is a directory
grep: /etc/pam.d: Is a directory
grep: /etc/pango: Is a directory
grep: /etc/passwd-: Permission denied
grep: /etc/pkcs11: Is a directory
grep: /etc/pm: Is a directory
grep: /etc/polkit-1: Is a directory
grep: /etc/profile.d: Is a directory
grep: /etc/pulse: Is a directory
grep: /etc/runit: Is a directory
grep: /etc/sane.d: Is a directory
grep: /etc/securetty: Permission denied
grep: /etc/security: Is a directory
grep: /etc/sgml: Is a directory
grep: /etc/shadow: Permission denied
grep: /etc/shadow-: Permission denied
grep: /etc/skel: Is a directory
grep: /etc/ssh: Is a directory
grep: /etc/ssl: Is a directory
grep: /etc/sudoers: Permission denied
grep: /etc/sudoers.d: Is a directory
grep: /etc/sv: Is a directory
grep: /etc/udev: Is a directory
grep: /etc/updatedb.conf: Permission denied
grep: /etc/vbox: Is a directory
grep: /etc/wpa_supplicant: Is a directory
grep: /etc/xdg: Is a directory
grep: /etc/xinetd.d: Is a directory
grep: /etc/xml: Is a directory
grep: /etc/zzz.d: Is a directory

This is how that effect took place
Quote:

%[userx@voided\~]>>$su
Password:
#
# bash -v
# /etc/bash/bashrc

# Do not edit this file.
# Place your readable configs in /etc/bash/bashrc.d/*.sh

if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi

if [ -d /etc/bash/bashrc.d/ ]; then
for f in /etc/bash/bashrc.d/*.sh; do
[ -r "$f" ] && . "$f"
done
unset f
fi
# .bashrc

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

alias ls='ls --color=auto'
PS1='[\u@\h rooty \W]\$ '
[root@voided rooty userx]#
ok I figured that out.

now the question changes to this.

Habitual 03-15-2016 01:57 PM

Code:

man grep
Search for "-R"

hydrurga 03-15-2016 01:59 PM

Why don't you just use

Code:

grep -rwn path -e pattern
Or am I just being silly as usual?

Edit: remove the "-w" if you don't want to only match whole words.

BW-userx 03-15-2016 02:02 PM

I got it it is in my /root directory ..
thanks!


All times are GMT -5. The time now is 03:41 PM.