LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-15-2016, 01:52 PM   #1
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,140

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
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.

Last edited by BW-userx; 03-15-2016 at 02:02 PM.
 
Old 03-15-2016, 01:57 PM   #2
Habitual
LQ Addict
 
Registered: Jan 2011
Posts: 8,249
Blog Entries: 11

Rep: Reputation: 2289Reputation: 2289Reputation: 2289Reputation: 2289Reputation: 2289Reputation: 2289Reputation: 2289Reputation: 2289Reputation: 2289Reputation: 2289Reputation: 2289
Code:
man grep
Search for "-R"
 
Old 03-15-2016, 01:59 PM   #3
hydrurga
Senior Member
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 18.1 MATE
Posts: 3,073

Rep: Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066
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.

Last edited by hydrurga; 03-15-2016 at 02:01 PM.
 
Old 03-15-2016, 02:02 PM   #4
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,140

Original Poster
Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
I got it it is in my /root directory ..
thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Search text file and find first line that matches an existing directory name AntBla Linux - Newbie 3 11-19-2013 05:27 AM
using find or grep to find a group of text strings. tkmsr Linux - Newbie 3 03-04-2011 07:02 AM
howto remove a particular phrase from a text file? jaggy00 Linux - Newbie 4 05-18-2007 06:27 AM
Which command to search text/phrase in file? b:z Linux - General 2 03-30-2005 09:11 PM
grep a phrase degraffenried13 Linux - General 1 04-04-2004 11:10 AM


All times are GMT -5. The time now is 11:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration