prushik on 24 Aug 2018 09:28:15 -0700
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] shell scripting help
|
- From: prushik <prushik@gmail.com>
- To: PhiladelphiaLinuxUser'sGroupDiscussionList <plug@lists.phillylinux.org>
- Subject: Re: [PLUG] shell scripting help
- Date: Fri, 24 Aug 2018 12:28:08 -0400 (EDT)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:message-id:mime-version; bh=i2DAjWhTZO7j0N6NUEdsLfGMWTs1h/UhF5VovFryEbM=; b=YpVqRJUYpud6I1xvSLsdd6in/2OuwGT/Kwk81Na6XvblS6j7NFZnxyRNOOG6dHIHGi LqCk4hMNsPQxkwWK+OykDeOY8lPfeIfvqKslR+ZyMGU6GO7a65EvqdnMXvM9rmlhDYA6 9ITk4yv65Jn3uJbbyILmWn2FXpkQaAS1zHQNjZxFAsCtq1cQdUy8wPnqHE0k4gnKS9Gh KprAorPM71pJ6ECrGd445kaSRagDP/8lpSUn+1xyGXRQngIpeyiJxfnw7/gYGCZaXRD7 5F7NaDtgzbBaVYdSq771YHzG89VjTGFxOIXN3iNmqh7hIHUxrNgkz274W5XdTU+8ar2I HfHQ==
- Reply-to: Philadelphia Linux User's Group Discussion List <plug@lists.phillylinux.org>
- Sender: "plug" <plug-bounces@lists.phillylinux.org>
Very few Linux users enjoy interactive scripts, but whatever floats your boat.
Your script has a few issues, but the biggest is that you seem to be confusing bash and php. $ is not a variable indicator in bash, its an expansion operator. This means that your read $i line gets expanded to read "", since i is unset at the beginning of the script.
Also remove done from the end of the script since you have no corresponding do.
---- Original message ----
From: Anthony Martin <anthony.j.martin142@gmail.com>
Sent: 08/24/2018 12:12:24
To: Philadelphia Linux User's Group Discussion List <plug@lists.phillylinux.org>
Subject: Re: [PLUG] shell scripting help
Have you tried setting it so you give the file name as an argument when you run the script? ./Script FILENAME
Anthony Martin
Linux System Administrator
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