From owner-freebsd-questions@FreeBSD.ORG Sun Jun 28 08:43:12 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5EDA61065678 for ; Sun, 28 Jun 2009 08:43:12 +0000 (UTC) (envelope-from gs_stoller@juno.com) Received: from outbound-mail.dca.untd.com (outbound-mail.dca.untd.com [64.136.47.15]) by mx1.freebsd.org (Postfix) with SMTP id 0F8B88FC18 for ; Sun, 28 Jun 2009 08:43:11 +0000 (UTC) (envelope-from gs_stoller@juno.com) X-UOL-TAGLINE: true Received: from outbound-bu1.dca.untd.com (webmail07.dca.untd.com [10.171.12.147]) by smtpout02.dca.untd.com with SMTP id AABFEQKX3AND6XCS for (sender ); Sun, 28 Jun 2009 01:15:53 -0700 (PDT) X-UNTD-OriginStamp: /s5f1SIGSI3+WdnoYQ8yRNmijqpkul1X0Y74ZitCjyuZbnQ0mneukQ== Received: (from gs_stoller@juno.com) by webmail07.dca.untd.com (jqueuemail) id PK5MYB6Q; Sun, 28 Jun 2009 01:15:02 PDT Received: from [71.167.150.114] by webmail07.dca.untd.com with HTTP: Sun, 28 Jun 2009 08:14:10 GMT X-Originating-IP: [71.167.150.114] Mime-Version: 1.0 From: "gs_stoller@juno.com" Date: Sun, 28 Jun 2009 08:14:10 GMT To: modulok@gmail.com, zhangweiwu@realss.com X-Mailer: Webmail Version 4.0 Message-Id: <20090628.041410.20175.0@webmail07.dca.untd.com> X-ContentStamp: 1:1:3765460757 X-MAIL-INFO: 3f21c4d189455d895d19458538e031b07051f0c9d049b52dd4999404b1541dd945a465d1316dedf5216d117944848444298464e095e1adc4c1155dd93874a0e40585a1747405b09dd50d61d98444e9cdf5d031a4 X-UNTD-Peer-Info: 10.171.12.147|webmail07.dca.untd.com|outbound-bu1.dca.untd.com|gs_stoller@juno.com Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-questions@freebsd.org Subject: Re: scripting suggestion: how to make this command shorter X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Jun 2009 08:43:12 -0000 On 6/27/09, Zhang Weiwu wrote: > Hello. I wrote this one-line command to fetch a page from a long uri, > parse it twice: first time get subject & second time get content, and > send it as email to me. > > $ w3m -dump > 'http://search1.taobao.com/browse/33/n-g,w6y4zzjaxxymvjomxy-----------= -----40--commen d-0-all-33.htm?at_topsearch=3D1&ssid=3De-s5' > | grep -A 100 =B6=D4=B1=C8 | mail -a 'Content-Type: text/plain; charse= t=3DUTF-8' -s > '=3D?UTF-8?B?'`w3m -dump > 'http://search1.taobao.com/browse/33/n-g,w6y4zzjaxxymvjomxy-----------= -----40--commen d-0-all-33.htm?at_topsearch=3D1&ssid=3De-s5' > | grep =D5=D2=B5=BD.*=BC=FE | base64 -w0`'?=3D' zhangweiwu@realss.com > > > The stupid part of this script is it fetches the page 2 times and pars= e > 2 times, thus making the command very long. If I can write the command= > in a way that the URI only appear once, then it is easier for me to > maintain it. I plan to put it in cron yet avoid having to modify two > places when the URI changes (and it does!). > > How do you suggest optimizing the one-liner? > Whenever I have to look through a long file more than onc= e, I copy the relevant sections into another file (a RAM file if it is s= hort enough and I have the RAM) and then parse it there as many times as= I need to do it. ____________________________________________________________ Criminal Lawyers - Click here. http://thirdpartyoffers.juno.com/TGL2141/fc/BLSrjpTOVoKXC2vT8bG75jmaBuBB= qrFnzp3RY2ufk0rwdaSjMZVA5BqOKCM/