AWK替换单引号 [英] Awk to replace single quote

查看:219
本文介绍了AWK替换单引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用include('替换一组文件中的所有include('./.我正在尝试如下使用awk:

I want to replace all include('./ in a set of files with include('. I am trying to use awk as follows:

awk '{gsub("include\('"'"'./", "include\('"'"'", $0); print > FILENAME}' *.php

它引发了我这个错误.

It throws me this error.

awk: (FILENAME=xyz.php FNR=1) fatal: Unmatched ( or \(: /include('.//

任何帮助将不胜感激.

推荐答案

@OP,您可以尝试将八进制代码用于单引号(\047)和正斜杠(\057),例如

@OP, you can try using octal code for the single quote(\047) and forward slash(\057), eg

$ cat file
include('./
$ awk '{gsub(/include\(\047\.\057/ , "include(\047" ) }1' file
include('

这篇关于AWK替换单引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆