I have a text file in the format
Full name email@ddress
It's a pretty long list of names and I want to remove all the email addresses from the file. I basically want to be left with a file with only the names of the persons, one on each line.
I tried :s [a-z]@[a-z] //g in vim but it did not work. It says E59: invalid charcter after @
how can I do this ?
thanks,
Sharukh.
Try this
%s/ ([a-z0-9A-Z.]*@[a-z0-9A-Z.]*)//gc
or u can try vertical select control+V
----- Original Message ----- From: "Dr. Sharukh K. R. Pavri." spavri@vsnl.com To: "Lug Bom" linuxers@mm.ilug-bom.org.in Sent: Wednesday, December 10, 2003 6:00 PM Subject: [ILUG-BOM] regexp query
I have a text file in the format
Full name email@ddress
It's a pretty long list of names and I want to remove all the email addresses from the file. I basically want to be left with a file with only the names of the persons, one on each line.
I tried :s [a-z]@[a-z] //g in vim but it did not work. It says E59: invalid charcter after @
how can I do this ?
thanks,
Sharukh.
On Wed, 10 Dec 2003, Sachin Rase wrote:
Try this
%s/ ([a-z0-9A-Z.]*@[a-z0-9A-Z.]*)//gc
It gives this: -------------------- E62: Nested @ Invalid command -------------------
regards,
Sharukh
On Thu, 11 Dec 2003, Sachin Rase wrote:
%s/ ([a-z0-9A-Z.]*@[a-z0-9A-Z.]*)//gc
Correction above works with VIM 5.8.7 ^^^^^^^ for VIM 6.2 @ =>@ then it works ^^^^^ %s/ ([a-z0-9A-Z.]*@[a-z0-9A-Z.]*)//gc
Inconvenience Regretted . :-(
oops:
Pattern not found: ([a-z0-9A-Z.]*@[a-z0-9A-Z.]*)
now what ?
how about
cat <textfile> | awk -F" " '{print $1}' On Wednesday 10 December 2003 18:00, Dr. Sharukh K. R. Pavri. wrote:
I have a text file in the format
Full name email@ddress
It's a pretty long list of names and I want to remove all the email addresses from the file. I basically want to be left with a file with only the names of the persons, one on each line.
I tried :s [a-z]@[a-z] //g in vim but it did not work. It says E59: invalid charcter after @
how can I do this ?
thanks,
Sharukh.
Dr. Sharukh K. R. Pavri. Mumbai, India.
On Thu, 11 Dec 2003, Vinayakam Murugan wrote:
how about
cat <textfile> | awk -F" " '{print $1}' On Wednesday 10 December 2003 18:00, Dr. Sharukh K. R. Pavri. wrote:
I have a text file in the format
Full name email@ddress
That worked the other way around. I was left with the email addresses, which is the opposite of what I want.
Sharukh.
oh yes, I'm sorry. You would have to do '{print $2}'. Anyways as proved later, this wouldn't work if the names contain spaces in them.
On Monday 15 December 2003 22:56, Dr. Sharukh K. R. Pavri. wrote:
On Thu, 11 Dec 2003, Vinayakam Murugan wrote:
how about
cat <textfile> | awk -F" " '{print $1}'
On Wednesday 10 December 2003 18:00, Dr. Sharukh K. R. Pavri. wrote:
I have a text file in the format
Full name email@ddress
That worked the other way around. I was left with the email addresses, which is the opposite of what I want.
Sharukh.
Dr. Sharukh K. R. Pavri Homeopath and Linuxer. Mumbai, India. http://www.pavri.net/
This should take care of the spaces as well
cat <textfile> | rev | awk -F" " '{print $1}' | rev
On Monday 15 December 2003 22:56, Dr. Sharukh K. R. Pavri. wrote:
On Thu, 11 Dec 2003, Vinayakam Murugan wrote:
how about
cat <textfile> | awk -F" " '{print $1}'
On Wednesday 10 December 2003 18:00, Dr. Sharukh K. R. Pavri. wrote:
I have a text file in the format
Full name email@ddress
That worked the other way around. I was left with the email addresses, which is the opposite of what I want.
Sharukh.
Dr. Sharukh K. R. Pavri Homeopath and Linuxer. Mumbai, India. http://www.pavri.net/
On Thu, 11 Dec 2003, Devdas Bhagat wrote:
On 10/12/03 18:00 +0530, Dr. Sharukh K. R. Pavri. wrote:
I have a text file in the format
Full name email@ddress
perl -e 'while(<>) { @names = split /\s+/; foreach (@names) { print "$_ " if ! /@/)}; print "\n" } ' < file.
Devdas Bhagat
That gives ---------------- syntax error at -e line 1, near "/@/)" Execution of -e aborted due to compilation errors. ------------------
Sharukh.
On 15/12/03 22:59 +0530, Dr. Sharukh K. R. Pavri. wrote:
On Thu, 11 Dec 2003, Devdas Bhagat wrote:
On 10/12/03 18:00 +0530, Dr. Sharukh K. R. Pavri. wrote:
I have a text file in the format
Full name email@ddress
perl -e 'while(<>) { @names = split /\s+/; foreach (@names) { print "$_ " if ! /@/)}; print "\n" } ' < file.
Devdas Bhagat
That gives
syntax error at -e line 1, near "/@/)" Execution of -e aborted due to compilation errors.
The whole command is a single line. I tested it before posting.
Devdas Bhagat
On Tue, 16 Dec 2003, Devdas Bhagat wrote:
On 15/12/03 22:59 +0530, Dr. Sharukh K. R. Pavri. wrote:
On Thu, 11 Dec 2003, Devdas Bhagat wrote:
On 10/12/03 18:00 +0530, Dr. Sharukh K. R. Pavri. wrote:
I have a text file in the format
Full name email@ddress
perl -e 'while(<>) { @names = split /\s+/; foreach (@names) { print "$_ " if ! /@/)}; print "\n" } ' < file.
Devdas Bhagat
That gives
syntax error at -e line 1, near "/@/)" Execution of -e aborted due to compilation errors.
The whole command is a single line. I tested it before posting.
Devdas Bhagat
I did use it as a single line. Sorry, still does not work :(
Sharukh
On 16/12/03 23:33 +0530, Dr. Sharukh K. R. Pavri. wrote: <snip> <reformatted code> perl -e 'while(<>) { @names = split /\s+/; foreach (@names) { print "$_ " if ! (/@/); } print "\n"; } ' < file.
<snip>
I did use it as a single line. Sorry, still does not work :(
Sorry, I missed the opening brace after the if.
[devdas@evita tmp]$ perl -e 'while(<>) { @names = split /\s+/; foreach (@names) { print "$_ " if ! (/@/)}; print "\n" } ' < users Devdas Bhagat Philip S Tellis Parul Mathur Dr. Shahrukh K. R. Pavri
[devdas@evita tmp]$ cat users Devdas Bhagat devdas@dvb.homelinux.org Philip S Tellis philip@ncst.ernet.in Parul Mathur parul.mathur@india.rsystems.com Dr. Shahrukh K. R. Pavri sparvi@vsnl.com
Devdas Bhagat
On Wed, 17 Dec 2003, Devdas Bhagat wrote:
On 16/12/03 23:33 +0530, Dr. Sharukh K. R. Pavri. wrote:
<snip> <reformatted code> perl -e 'while(<>) { @names = split /\s+/; foreach (@names) { print "$_ " if ! (/\@/); } print "\n"; } ' < file.
<snip> > I did use it as a single line. Sorry, still does not work :( Sorry, I missed the opening brace after the if.
Thanks, that worked.
Sharukh.
On 11/12/03 09:52 +0530, Devdas Bhagat wrote:
On 10/12/03 18:00 +0530, Dr. Sharukh K. R. Pavri. wrote:
I have a text file in the format
Full name email@ddress
perl -e 'while(<>) { @names = split /\s+/; foreach (@names) { print "$_ " if ! /@/)}; print "\n" } ' < file.
Replying to myself:
The above one liner is equivalent to: #!/usr/bin/perl
while (<STDIN>) { #read one line from standard input @names = split /\s+/; #Split the line on whitespace #and assign to the array @names
foreach (@names) { #For all values in the array print "$_ " #Print the value followed by a single # space if ! /@/; #Iff there was no '@' in it. } print "\n"; #Print a newline }
I redirect standard input from the file 'file' via the shell operator <.
Devdas Bhagat
Hi Just Try these Ones And See whether It works or not!
:s/s1/s2 replace (``substitute'') (the first) s1 in this line by s2
:lr/s/s1/s2/g replace all instances of s1 in the line range lr by s2 (lr is of form `a,b', where a and b are either explicit line numbers, or . (current line) or $ (last line)
--------------------------------- Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing
On Wed, 10 Dec 2003, Sharukh K. R. spake thusly:
I have a text file in the format
Full name email@ddress
It's a pretty long list of names and I want to remove all the email addresses from the file. I basically want to be left with a file with only the names of the persons, one on each line.
cat filename.txt | cut -d ' ' -f 1,2 > newfile.txt
:)
On Mon, 15 Dec 2003, q u a s i wrote:
On Wed, 10 Dec 2003, Sharukh K. R. spake thusly:
I have a text file in the format
Full name email@ddress
It's a pretty long list of names and I want to remove all the email addresses from the file. I basically want to be left with a file with only the names of the persons, one on each line.
cat filename.txt | cut -d ' ' -f 1,2 > newfile.txt
:)
Nope, did not work :(
sharukh.
I have a text file in the format
Full name email@ddress
It's a pretty long list of names and I want to remove all the email addresses from the file. I basically want to be left with a file with only the names of the persons, one on each line.
You can try the following in vim. :0,$ s/(.*[^@].*) (.*@.*)/\1/