LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-04-2005, 06:47 AM   #1
paul_mat
Member
 
Registered: Nov 2004
Location: Townsville, Australia
Distribution: Fedora Core 5, CentOS 4, RHEL 4
Posts: 855

Rep: Reputation: 30
remove text from file with script


hi there,

i've got a text file with a list of email adresses and what i want to do is strip away all the information after the '@'

so turn

user1@example.com
user2@example.com
user3@example.com
user4@example.com

to ..

user1
user2
user3
user4
 
Old 11-04-2005, 06:55 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Have another sed one-liner
Code:
sed 's/@.*$//' /path/to/file
Dave

Last edited by ilikejam; 11-04-2005 at 06:59 AM.
 
Old 11-16-2005, 08:00 PM   #3
paul_mat
Member
 
Registered: Nov 2004
Location: Townsville, Australia
Distribution: Fedora Core 5, CentOS 4, RHEL 4
Posts: 855

Original Poster
Rep: Reputation: 30
hi ilikejam

i got another sed question i thought you might be able to help me out on.

i was wanting to put the output of this into a variable

sed 's/.*: //' /tmp/tmp

do you know how that can be done?

Last edited by paul_mat; 11-16-2005 at 08:06 PM.
 
Old 11-17-2005, 01:21 PM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Sure.
Code:
MYVARIABLE=`sed 's/.*: //' /tmp/tmp`
Dave
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove odd lines from a text file Mr. Gone Programming 2 09-19-2005 12:16 PM
How to find and change a specific text in a text file by using shell script Bassam Programming 1 07-18-2005 08:15 PM
Create text file with a script zael Programming 3 06-02-2004 04:27 AM
How to remove line of text from file netkepala Linux - General 2 05-23-2003 12:49 PM
how to convert a text file into shell script meng_en Linux - General 9 10-15-2002 11:46 PM


All times are GMT -5. The time now is 07:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration