Go hokies分享 http://blog.sciencenet.cn/u/cobra22

博文

A simple method "perl pie "to replace strings in multiple files on Linux system

已有 4758 次阅读 2010-5-29 01:20 |个人分类:科研笔记|系统分类:科研笔记

 find ./SRC/ -name "*.f90" | xargs perl -pi -e 's/iargc()/COMMAND_ARGUMENT_COUNT()/g'

try to replace each occurrence of iargc() with COMMAND_ARGUMENT_COUNT() in directory ./SRC for all files with suffix .f90. Parentheses should be included by to indicate they are normal characters in the context.

This method is usually called perl-pie because of the option -pi -e.
  • The -p argument allows perl to loop over all files or lines passed as arguments.
  • The -i argument has perl write the changes to the input file, and allows for backups with the optional field <backup-ext>.
  • The -e argument specifies a line of perl code to execute. Multiple lines can be executed when separated with ; s.


https://blog.sciencenet.cn/blog-398465-329831.html

上一篇:自适应步长Runge-Kutta-Fehlberg method for solving ODE system的matlab实现
下一篇:How to bind CUDA 3D array to texture memory
收藏 IP: .*| 热度|

0

发表评论 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-11-25 11:01

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部