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

Yuki Kimoto - SPVM Author - Dec 17 '22 - - Dev Community

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.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .