DEV Community

Yuki Kimoto
Yuki Kimoto

Posted on

5

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.

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay