DEV Community

Yuki Kimoto - SPVM Author
Yuki Kimoto - SPVM Author

Posted on

A recent Perl one-liner on Linux that has Really Helped me as an IT engineer

Recently used Perl one-liner on Linux to replace the strings in SPVM source codes.

This command is dangerous because it does replacement

find * | grep -P '\.(spvm|c|h|xs|y|pm|pod|t)$' | xargs perl -pi -e 's/descriptor/attribute/g'
Enter fullscreen mode Exit fullscreen mode

For Programming Beginners

find * searches all files except for hidden files in the current directory.

| is the pipe.

grep -P '\.(spvm|c|h|xs|y|pm|pod|t)$' extracts files of the specific extensions.

xargs passes each file from the pipe as an argument of the command and executes the command.

perl -pi -e 's/descriptor/attribute/g' replaces all descriptor with attribute.

Top comments (1)

Collapse
 
rwp0 profile image
Elvin Aslanov

Could also do the same with sed -i.