LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-19-2005, 02:52 PM   #1
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Rep: Reputation: 55
Problem with reg exp script


# cat /etc/userdomains | grep test
test.com: test

How can I grep just the domain "test.com"?

I tried cat /etc/userdomains | awk {'print $2'}
but it gets
test.com:

how can I get it to not get the : ?

Thanks in advance.
 
Old 12-19-2005, 03:10 PM   #2
sirclif
Member
 
Registered: Sep 2004
Location: south texas
Distribution: fedora core 3,4; gentoo
Posts: 192

Rep: Reputation: 30
you could do:

Code:
#cat /etc/userdomains | gawk -F":" '{print $1}'
i think you meant to print the first column with gawk, or...

Code:
#cat /etc/userdomains | sed "s/\(^.*\):.*/\1/
 
Old 12-19-2005, 03:53 PM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Yet another way:
Code:
cat /etc/userdomains | cut -d: -f1
 
  


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
Perl Reg Exp Question amytys Programming 1 12-09-2005 12:53 PM
Need REG EXP Help to remove line breaks webshark Programming 18 07-08-2005 04:31 PM
need clarification in this reg exp/awk code mselvam Linux - General 1 07-08-2005 03:57 PM
prob with reg exp rajatgarg Programming 3 05-28-2004 09:21 AM
Reg Exp ugenn Programming 4 09-19-2002 12:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:25 AM.

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
Open Source Consulting | Domain Registration