Answer» hi all, semi-newbie confused.......i am trying to write a script that searches all users directories for words that are certain colors...such as red, blue, so on.......then the display must output this sentence: Username:username, PART of file with the colored word:The BALL is red., Path:/john/mydocs/red.doc
I have played around with this, COMING up with different things but nothing close so here is what i have settled on thus far:
colors='grep -E -r "red|blue|green|yellow" /home' nameofuser='echo $colors | cut -d "/" -f3' line='echo $colors | cut -d ":" -f2 | cut -d "/" -f1` path=`echo $colors | cut -d ":" -f1`
echo "Username:$nameofuser, Part of file with colored word:$line, Path:$path
This is what i have so far. It gives me only the first instance of course. Am I on the right track even on this? If so i know a loop is somehow NEEDED. But I keep secondguessing myself if i even have it right to this point. This shouldnt get too complex considering like i SAID i am a newbie. Please help!! Just to clarify the output should look similiar to this:
Username:....., Line with color.........., Path: Username......,Line with color............,Path: Username......,Line with color............,Path:
and so on
Any help would be greatly appreciated.
|