Carlos M. Fernández on 24 Aug 2018 09:23:14 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] shell scripting help


That 'done' at the end looks copy-pasted from a do/done block.

Also, you don't use the dollar sign with "read", so that line should say "read i;".

Here's a simpler version:

#!/bin/bash
echo "What is the filename you want to grep?";
read i;
OUTPUT=$(egrep '\b[A-Z]+| [0-9:]+ \b' "$i" |egrep -v 'anaged|No|Na|Ser|Ty|Contact' |sort -u);
echo "${OUTPUT}";

Best regards,
//CMFM


On Fri, Aug 24, 2018 at 12:04 PM Michael Lazin <microlaser@gmail.com> wrote:
I am trying to write a shell script to automate the formatting of a text file in a certain way that is useful to me.  the complicated egrep while not ideal does the job when run alone, where $i is the name of the file I want to grep, but when I try put it together in an easy to run script it doesn't do anything.  Can someone please point me in the right direction?  Thank you.  

#!/bin/bash
echo "What is the filename you want to grep?";
read $i;
OUTPUT="$(egrep '\b[A-Z]+| [0-9:]+ \b' $i | grep -v anaged | grep -v No| sort -u | grep -v Na | grep -v Ser | grep -v Ty | grep -v Contact)";
echo "${OUTPUT}";
done


--
Michael Lazin

to gar auto estin noein te kai ennai
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug