Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] sed and awk



On Wed, Apr 10, 2002 at 09:49:34PM -0700,
Michael Moyle wrote:

> 
> Just for fun: 
> 
> Does anyone have any examples of their favorite uses for sed and/or awk? 

I use awk a lot for this type of one-liner:

	awk '{print $1}' tabular_file

I've never found sed to be useful for anything I couldn't do efficiently
with perl, however.  But then again, it's been years since I've been
forced to work on perl-free Unix machines.

> I have not worked much with either tool, and want to see how they
> interplay, and what each is best at. 
> 
> Or if you feel perl has superceded them, post a perl example. 
                               ^
<spelling nazi>superSeded!</spelling nazi>

> Right now I am using sed to go through and replace all the package names
> in a bunch of of java files. And I started thinking about awk.

perl -pi.bak -e 's/old_package_name/new_package_name/g' \
	`find . -name "*.java" -print`

-- 
Shimpei Yamashita                               http://www.shimpei.org/
perl -w -e '$_="not a perl hacker\n";$q=qq;(.);x9;$qq=qq;345123h896789,;;$s=
pack(qq;H6;,q;6a7573;);$qq=qq;s,^$q,$s$qq;;$qq=~s;(\d);\$$1;g;eval$qq;print;'


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links