Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-01-2007, 06:25 AM   #1
Registered: Oct 2007
Posts: 101

Rep: Reputation: 15
Thumbs up Urgent

I am writing a "Registeration program" code using gtkdialog(in bash scripting) . I make a log file into which user's information are saved.
I have to read that file to check, username should not contain space or any kind of special character. i am taking too much time for it, plz help me

Last edited by kkpal; 11-01-2007 at 06:26 AM.
Old 11-01-2007, 08:25 AM   #2
LQ Newbie
Registered: Apr 2007
Distribution: Ubuntu 7.10
Posts: 21

Rep: Reputation: 15
Use egrep

OK so let's say your usernames are saved in a file called users.txt

Do this:

egrep [^A-Za-z] users.txt

This will output all the 'bad' usernames - any line of the file where the username contains characters which are not upper or lower case letters.

Note this also excludes numbers. If you want to allow numbers, change the pattern to:

egrep [^A-Za-z0-9] users.txt

Google 'regex' to learn more about specifying patterns. A brief explanation of the pattern in my example:

in this context, the ^ symbol means we are matching any line that contains something other than the following patterns, which are alphabet uppercase (the A-Z part), then lowercase (a-z) then numbers (0-9).

If you want to capture the results in a file, just do

egrep [^A-Za-z] users.txt > bad_usernames.txt


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
boot sector and lilo collapse !!!!! URGENT URGENT URGEN !!!!! frelihm Linux - Software 21 12-02-2009 11:21 AM
Urgent Question Regarding Urgent Questions! Need Help Now! Crashed_Again LQ Suggestions & Feedback 11 10-17-2007 09:07 PM
Urgent..Im Having A Nightmare..Urgent!!!! midgcool Linux - Software 41 11-30-2004 11:19 AM
Urgent Urgent !!!! Mozilla Keeps All Your Deleted Emails !!!! odin123 Linux - Software 2 01-31-2004 03:22 AM
Urgent linuxaddict Linux - Networking 9 11-23-2003 06:17 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:46 PM.

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