[Ilugc] Regex Help (Ravi Jaya)
- From: mrugeshkarnik@xxxxxxxxx (Mrugesh Karnik)
- Date: Tue Sep 25 17:06:32 2007
Hi,
Creating a new thread because the original was hijacked.
Dear luggies,
I want to grep from the file, the words which start with & and close with
; eg( ,& ...) to write this is in to another file. how could i
fetch an individual word. and also it is regx is an ideal way of this.
please help me with the examples or the resources where i could dig more
abt regx.
thanks
Ravi
Try this:
echo -e "foo\nar\nbaz\n \nbah\nblah\n \n;jgei\n&;\n&\nfoo_bar;" | \
sed -n 's/&[a-z]\{1,\};/&/gpw nbsp'
You should see the output on your terminal window and it'll also be written to
the file nbsp.
I didn't understand if you wanted the whole line or just the matched word
written to the file. The above will write out only the matched word.
In case you want the whole line written out, look up O'Reilly's sed & awk. Its
worth it. :)
HTH.
--
----------------------------------------
Mrugesh Karnik
GPG Key 0xBA6F1DA8
Public key on
http://wwwkeys.pgp.net
----------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url :
http://www.ae.iitm.ac.in/pipermail/ilugc/attachments/20070925/794bba37/attachment.bin
Other related posts:
- » [Ilugc] Regex Help (Ravi Jaya) - Mrugesh Karnik