I am new to shell scripting and programming. I am looking for a guide on how I can parse specific information from a plain text file with thousands of lines. Specifically I need to parse an email address from each line. The line looks something like this:
I would like to extract the email address (exluding the < and >) and then perform an update statement via mysql with the email address as a value.
Is there an example of this somewhere that I could use to base my needs off of?
What scripting tool would I use, how do I tell that tool to gab all contents BETWEEN the < and >?
How do I then (within one script) use this value to update a DB record?
p.s. I am essentially trying to unsubscribe these email addresses from a contact database..
Thanks for the help.
John
---------- Post updated at 01:19 PM ---------- Previous update was at 01:15 PM ----------
The SQL statement that needs to be run is:
Last edited by Scott; 11-19-2010 at 04:14 PM..
Reason: Please use code tags
That worked like a charm. I have looked up your syntax and now understand how that works. I will now research how to use a while loop. Would you recommend a bash script?
I edited my response. It was a typo. It was meant to say 'I will now research'
After reading on bash I can accomplish my mysql execution using a defined variable (variable = email address) but am not sure how to read a file and have the mysql execute the statement for each line (i.e. email) value.
I just dont know how to incorporate the awk statement that parses my emails and loop it into the above bash script which updates DB.
Hello:
I have some text output, on SunOS 5.11 platform using KSH:
I am trying to parse out each string within the () for each line.
I tried, as example:
perl -lanF"" -e 'print "$F $F $F $F $F $F"'
But for some reason, the output gets all garbled after the the first fields.... (8 Replies)
I cannot seem to get what should be a simple awk one-liner to work correctly and cannot figure out why. I would like to use patterns from a specific field in one file as regex to search for matching strings in the entire line ($0) of another file.
I would like to output the lines of File2 which... (1 Reply)
Hello Everyone ,
Iam a newbie to shell programming and iam reaching out if anyone can help in this :-
I have two files
1) Insert.txt
2) partition_list.txt
insert.txt looks like this :-
insert into emp1 partition (partition_name)
(a1,
b2,
c4,
s6,
d8)
select
a1,
b2,
c4, (2 Replies)
Dear all,
I have a data like below (n of rows=400,000) and I want to extract the rows with certain strings. I use code below. It works if there is not too many strings for example n of strings <5000. while I have 90,000 strings to extract. If I use the egrep code below, I will get error:
... (3 Replies)
The question is not as simple as the title... I have a file, it looks like this
<string name="string1">RZ-LED</string>
<string name="string2">2.0</string>
<string name="string2">Version 2.0</string>
<string name="string3">BP</string>
I would like to check for duplicate entries of... (11 Replies)
Hello guys,
should be a very easy questn for you:
I need to delete strings in file1 based on the list of strings in file2.
like file2:
word1_word2_
word3_word5_
word3_word4_
word6_word7_
file1:
word1_word2_otherwords..,word3_word5_others... (7 Replies)
Hey guys,
I have this file generated by me... i want to create some HTML output from it.
The problem is that i am really confused about how do I go about reading the file.
The file is in the following format:
TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
I have a file with the following format
12g data/datasets/cct 8g data/dataset/cct
10 g data/two 5g data/something_different
10g something_different
5g data/two
is there a way to loop through this... (1 Reply)