Sep 17, 2011

One liner is a good way to do some smaller jobs in your life


Perl one liner is a good way to do some smaller jobs in daily life like renaming a file name or showing a file list.

You may think that you can do it by writing a script or a program. But one of the advantages of one liner is that you can combine it with other command like UNIX pipe and filter.

Here is an example of Perl one liner. You can pick up source files and header files for C/C++ language. It is not so difficult.

perl -MFile::Find -e 'find(sub {print "$File::Find::name\n" if $File::Find::name =~ /\.(c|cpp|h)$/ }, ".")'

You may say that you want to write other language. It is OK. You can use any LL but you may have some limitation in older OS. For example, I am using Open VMS, which is OS by HP, and I can use only Perl in LL. It is good to learn basic of other language for you.

I hope you will write some one liner in your work :)

No comments:

Post a Comment