[PLUG] simple grep
Keith Morse
kgmorse at mpcu.com
Wed May 21 18:00:16 UTC 2003
Russel, I'd recommend posting this to the shell-scripting list located
at moongroup.com.
Shell.scripting at moongroup.com
http://moongroup.com/mailman/listinfo/shell.scripting
It's low volume and there are a couple of incredibly sharp people that are
list members.
On Wed, 21 May 2003, Russell Evans wrote:
> I'm learning and I am now seeing that Bash provides ways to manipulate
> variables without calling external programs and using pipes. I first noticed I
> could replace the calls to cut and sed I was using with ${VAR//pattern/word}. I
> have replaced a call to wc -c by using ${#VAR}. now I want a simple grep and
> grep -v. I don't need it to be perfect but would like it to as workable as
> possible. I would like to replace [A-Za-z0-9\ \
> \~\!\@\#\$\%\^\&\*\(\)\_\+\=\{\}\'\"\:\;\<\>\,\.\/] with classes; [:alnum:]
> .. but I can't get it to work. Any help appreciated.
>
> Thank you
> Russell
>
> #!/bin/sh
>
> VAR=$1
> FILE=$2
>
> while read LINE ; do
> PRE=${LINE//$VAR/??--??/}
> CAP=${PRE//[A-Za-z0-9\ \
> \~\!\@\#\$\%\^\&\*\(\)\_\+\=\{\}\'\"\:\;\<\>\,\.\/]}
> if [ "$CAP" = "??--??" ] ; then
> echo $LINE
> fi
> done < $FILE
>
>
>
>
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>
More information about the PLUG
mailing list