String questions from shell script

Dave Tiger dave at tigeri.com
Thu Apr 15 14:10:48 BST 2004


Thanks Sam for that.

I had tried cut but my format was wrong so thank you for your help

Now onto finding my string in a file and writing a line under it.

This reminds me of when I started Php :-)

Dave C


--------------------------------------------
EPH Group Ltd.
Professional UK Based Web Hosting 
http://www.ephgroup.com  
In the UK? Call FREE: 0800 031 9190
Unlimited WebSpace, Unlimited Email Accounts, FREE Telephone Support,
FREE co.uk domain name, FAST FRIENDLY SERVICE, UNIX & Windows accounts
--------------------------------------------

-----Original Message-----
From: Sam [mailto:freebsd at pikesley.org] 
Sent: 15 April 2004 14:03
To: Dave Tiger
Cc: freebsd-users at uk.freebsd.org
Subject: Re: String questions from shell script


On Thu, 2004-04-15 at 13:53, Dave Tiger wrote:
> Hi List,
> 
> Thanks Roger (without d) for your great help earlier.
> 
> I now ask the list if you could help me with two string related 
> questions.
> 
> The first is how do I split a string. From my earlier question Roger 
> showed me how to connect MySql using sh and return values.
> 
> $col2 is one vale that returns and email address ie user at example.com 
> and I would like to know how to split that to be left with only 
> example.com. I have tried "split($col2,a,"@") but I keep getting 
> errors saying "Syntax
> error: word unexpected (expecting ")")  " and this is confusing me.

	echo user at example.com | cut -d'@' -f 2 

ought to do it. If you want to assign it to a variable, do this: 

	MYSTRING=`echo user at example.com | cut -d'@' -f 2`

> 
> Second. Once I have "example.com" how do I search a file for that and 
> write a line underneath its where it is found in the file.
> 
> These are the only two bits that draw a blank searching the web and 
> looking at my books so if anyone could help with this I would really 
> appreciate it.
> 
> Thank you in advance for any help or guidance
> 
> Dave C
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.657 / Virus Database: 422 - Release Date: 13/04/2004
>  
> 
> 
> ------ FreeBSD UK Users' Group  -  Mailing List ------ 
> http://listserver.uk.freebsd.org/mailman/listinfo/freebsd-users
-- 
Sending this message was important to us. We considered ourselves to be a
powerful culture.

                    http://downlode.org/etext/wipp/


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.657 / Virus Database: 422 - Release Date: 13/04/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.657 / Virus Database: 422 - Release Date: 13/04/2004
 





More information about the Ukfreebsd mailing list