Extracting email address using basename


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extracting email address using basename
# 1  
Old 10-16-2008
Extracting email address using basename

Is it possible to use a variable as the delimiter using basename?

I have a num variable that will be changing in the filename now.
The files could looke like this

my.email.address@mydomain.com.VL010600_474
my.email.address@mydomain.com.VL020600_474
my.email.address@mydomain.com.VL030600_474
my.email.address@mydomain.com.VL040600_474

I'm tryin to loop thru and use a variable for the delimiter.

delim=".VL0$num0600_474"
email=`basename $f $delim`
echo "email = $email " >> /home/myname/xls.logfile

When I look at the email variable, it has the delimiter tacked on to it instead of just the email address.

I really appreciate all the suggestions.
# 2  
Old 10-16-2008
Hammer & Screwdriver

I think you can do a basename with variable - just can't think of it off the top of my head. However, see the following that may be able to help:

Code:
> var1="Doe"       
> echo "JohnDoe" | sed "s/$var1/~&/"
John~Doe
> echo "JohnDoe" | sed "s/$var1/~&/" | cut -d"~" -f1
John

Effectively cutting the text that occurs with/after your var1
# 3  
Old 10-16-2008
Code:
for file in *@*.VL0*_*;do echo ${file%\.*} >>/home/myname/xls.logfile;done

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script extracting ip address from MAC wifi card

Hi Everybody, Goal: From my backup box on my local network, knowing the Wifi MAC address of my laptop, I would like to dynamically identify which ip address is attributed to my laptop. The aim is to store this ip address in a local variable and that this information is retrieved by another... (11 Replies)
Discussion started by: freddie50
11 Replies

2. Forum Support Area for Unregistered Users & Account Problems

Cant use certain email address

I tried to re-register using my new email address which is <firstname>@<surname>.me But it never sent out the email confirmation. I had to hit the back button and use my gmail address instead and it came through instantly. Is there a problem with using .me addresses? (1 Reply)
Discussion started by: frustin
1 Replies

3. Shell Programming and Scripting

extracting basename in awk or nawk

I am having a hard time extracting the file name from the above code. Instead of printing /folder/file.1$.5$, I would like it to print the file name file.1$.5$. I have tried using basename but it looks like NAWK or AWK does not recognise basename. Each time I type it in, it prints out the word... (4 Replies)
Discussion started by: asemota
4 Replies

4. Shell Programming and Scripting

extracting the ip address from ifconfig

Hi I am trying to create a script extracting the IP provided by ifconfig. I tried with grep + awk but I am returned more than I need. /sbin/ifconfig eth0 | grep "inet addr:" | awk '/inet addr:/ { print $2 }' and returns addr:10.15.1.64 How can I remove "addr:" string?... (9 Replies)
Discussion started by: manustone
9 Replies

5. Shell Programming and Scripting

Sender email address has to changes

I am sending email with attachment using mail and uuencode command. Ex: (echo "$EMAIL_BODY"; uuencode $FILE ATTACH.TXT) || mail "$EMAIL_ID" -s "$EMAIL_SUB" I am getting email from "applmgr@rigelapp01.us.dell.com". I want to change this email address into... (1 Reply)
Discussion started by: balajiora
1 Replies

6. UNIX for Dummies Questions & Answers

redirection to email address

Can someone please tell me the format to redirect an output file to an email address? thanks (4 Replies)
Discussion started by: 4Given
4 Replies

7. Shell Programming and Scripting

Extracting part of the basename

Hi, I was wondering if there is an easy way to strip off the required basename. I have a script called apb0110021.sh and the contents of the script are typeset -u MScript=`basename $0 | cut -d. -f1` scriptname=sys.Audit.ksh parms="PROJECT1 dsAudit $MScript 1 BEGIN" $SCRIPTS/$scriptname... (3 Replies)
Discussion started by: madhunk
3 Replies

8. UNIX for Dummies Questions & Answers

Send email where # is in the email address - Using Unix

Hi All, How do I send an email using malix where email address contains a #. I have a email address like this : #test@test.com I want to send email like malix -s "TEST" #test@test.com < SOMEFILE I tried \# but doesn't work. Please let me know how we can achieve this? I am in... (1 Reply)
Discussion started by: jingi1234
1 Replies

9. Post Here to Contact Site Administrators and Moderators

i have removed my email address

I have removed my email address from the posted email. what else do I need to do? Thanks K-one (1 Reply)
Discussion started by: K-ONE
1 Replies
Login or Register to Ask a Question