| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
Search for words in a text file
|
Original Message
|
Name: Mitesh
Date: September 17, 2007 at 04:09:15 Pacific
Subject: Search for words in a text fileOS: UnixCPU/Ram: Intel, 512MBManufacturer/Model: Dell |
Comment: Hi, I am a unix newbie. I am trying the following to search for a number of words in a text file (@unix command prompt), but the entire file contents are displayed. Can anyone tell me where I am making a mistake? Thanks Mitesh for i in `cat /tmp/mylist` > do > grep i /etc/passwd > done mylist contains Users names. Thanks Mitesh
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: nails
Date: September 17, 2007 at 07:24:39 Pacific
|
Reply: (edit)#!/bin/ksh # untested as I'm not near a unix box and # I'm assuming there's one word per line while read i do grep "$i" /etc/passwd done < /tmp/mylist
Report Offensive Follow Up For Removal
|

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