Computing.Net > Forums > Unix > shell script help please

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

shell script help please

Reply to Message Icon

Name: Gordy
Date: April 6, 2003 at 22:56:17 Pacific
OS: Unix
CPU/Ram: na
Comment:

Hi everyone...

I posted about this before, but I'm still having some problems. My script below reads (or trys to at least) read in lines of a file and then see if some part of the line matches the input from the user, $1..

Here's a sample text file that I have been using with some random images... if I search for "cookie", the image for cookie is displayed 8 times... I want it to display once.. and if I search for book.. i want picture 7 and 1 to show up..

Any help would be REALLY appreciated.. thanks.

glg2296/art/images/picture1.jpg:author:cookie
glg2296/art/images/picture2.jpg:author:chair
glg2296/art/images/picture3.jpg:author:apple
glg2296/art/images/picture4.jpg:author:grapes
glg2296/art/images/picture5.jpg:author:car
glg2296/art/images/picture6.jpg:author:monkey
glg2296/art/images/picture7.jpg:author:book
glg2296/art/images/picture1.jpg:author:book

#!/bin/sh
echo "Content-type: text/html"
echo


counter=`wc -l "


for (( i=0; i"

#cat line.txt

#grep "$1" database.txt >temp.txt

#grep "$1" $line > results.txt

grep $1 database.txt> temp.txt

#cat temp.txt

p=`awk -F: '{print $1}' temp.txt | sed 's#//##'`
#p=`awk -F: '{print $1}' results.txt | sed 's#//##'`

#cat temp.txt
echo ""
echo ""


#rm temp.txt



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: April 7, 2003 at 07:26:21 Pacific
Reply:

Gordy:

A common technique is to use the uniq command:

# untested
p=`awk -F: '{print $1}' temp.txt |uniq| sed 's#//##'`

Regards,

Nails


0
Reply to Message Icon

Related Posts

See More


Send it...Plz! Find skipping files



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: shell script help please

c shell script help PLEASE www.computing.net/answers/unix/c-shell-script-help-please/4355.html

Borland Shell Script - HELP!!! www.computing.net/answers/unix/borland-shell-script-help/2116.html

Korn Shell script help please!! www.computing.net/answers/unix/korn-shell-script-help-please/4345.html