Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: manipulatin...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 9 Topic 2160 of 2236
Post > Topic >>

Re: manipulating texts

by Ed Morton <morton@[EMAIL PROTECTED] > Feb 12, 2008 at 08:52 AM

On 2/12/2008 8:48 AM, Ed Morton wrote:
> 
> On 2/12/2008 8:18 AM, Minalba Jordao wrote:
<snip>
>>If I need to to that, with many files? Could I do it with awk? Or will
>>I need to use some shell scripting?
> 
> 
> You can do it with awk:
> 
> awk ' FNR==1 { outfile=FILENAME ".new" }

Forgot to re-init the variables ("a" not strictly necessary):

awk ' FNR==1 { outfile=FILENAME ".new"; a=b=0 }

>       /^@[EMAIL PROTECTED]
 { print > outfile; a=!a; b=1; next }
>       a || /^!/ { print > outfile; next }
>       b { print $1,$2,"-"$3 > outfile}' *.dat
> 
> but your OS is typically better suited for the job, especially if you
want to
> replace the original files with the modified ones.




 9 Posts in Topic:
manipulating texts
Minalba Jordao <minalb  2008-02-12 04:57:31 
Re: manipulating texts
Minalba Jordao <minalb  2008-02-12 05:08:17 
Re: manipulating texts
Ed Morton <morton@[EMA  2008-02-12 07:18:19 
Re: manipulating texts
Ed Morton <morton@[EMA  2008-02-12 07:15:37 
Re: manipulating texts
Minalba Jordao <minalb  2008-02-12 05:23:03 
Re: manipulating texts
Ed Morton <morton@[EMA  2008-02-12 07:33:05 
Re: manipulating texts
Minalba Jordao <minalb  2008-02-12 06:18:06 
Re: manipulating texts
Ed Morton <morton@[EMA  2008-02-12 08:48:22 
Re: manipulating texts
Ed Morton <morton@[EMA  2008-02-12 08:52:37 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 23:04:49 CDT 2008.