UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old May 17th, 2004, 10:44 PM
CGrantham CGrantham is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 43 CGrantham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
BASH Script, read a line from a file

Hi, I'm trying to write a BASH script that uses a file containing a list of user names:
cg776
jcq448
dfs
etc...
I want to read each line into a string, then run:
Code:
               finger | grep FRIEND                 


or something to that affect, then I need to determine if the user supports real time chat (the '*' somewhere in the line of output from finger for that user I think...)

If anyone could lend a hand it would be appreciated...

Reply With Quote
  #2  
Old May 18th, 2004, 04:10 AM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,296 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 1 h 5 m 42 sec
Reputation Power: 101
Send a message via ICQ to christo Send a message via Yahoo to christo
I have a file called names, which looks like:

chris
cristi
spira
erik

I have a script called namelooper.sh which looks like:
Code:
#!/bin/bash

NAMES=`cat names`
for i in $NAMES
do
        RESULT=`finger $i`
        echo $RESULT
done


when I chmod 777 namelooper.sh and then run it, I get the following output - tidy it up as you like:

Quote:
bash-2.05b# ./namelooper.sh
Login: chris Name: chris lacy-hulbert Directory: /home/chris Shell: /bin/bash Office: On since Tue May 18 09:51 (BST) on pts/0 from office.enovi.com On since Tue May 18 09:53 (BST) on pts/2 from office.enovi.com 2 minutes 27 seconds idle No mail. No Plan.
finger: christi: no such user.

Login: erik Name: (null) Directory: /dev/null Shell: /bin/false Never logged in. No mail. No Plan.
Login: spira Name: spiration cvs user Directory: /home/spira Shell: /bin/bash Last login Mon May 5 10:21 2003 (BST) on pts/2 from 10.0.0.15 No mail. No Plan.
Login: angus Name: Fred Lacy-Hulbert Directory: /home/fred Shell: /bin/bash Never logged in. No mail. No Plan.
Login: root Name: (null) Directory: /root Shell: /bin/bash Last login Thu Apr 29 19:40 (BST) on pts/2 from 192.168.1.10 Mail last read Wed Sep 24 18:53 2003 (BST) No Plan.


hth
christo

Last edited by christo : October 30th, 2006 at 08:25 AM.

Reply With Quote
  #3  
Old July 18th, 2004, 01:50 PM
tgkprog tgkprog is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 3 tgkprog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 m
Reputation Power: 0
Question

how do i get to see the lines i read and search them for a particular char - I need to read and ignore a file till i find a certain string and then write out the rest of the file in to another file using sh ... can some one help ? thanks

i tried using cat and a for loop but that breaks up the lines into words ... and the echo -n option does not work with my sh ... so it puts the words in seperate lines .

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > BASH Script, read a line from a file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway