在引号SED,向前的斜线 [英] sed, foward slash in quotes

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

问题描述

我试图做庆典一些与 SED 被证明是极其困难的。

I'm trying to do something in bash with sed that is proving to be extremely difficult.

我有一个庆典脚本,它作为第一个参数的日期。

I have a bash script that takes as its first argument a date.

在code要换一行在文本文件中,包括传递日期。这里的code

The code want to change a line in a text file to include the passed date. Here's the code

#!/bin/bash

cq_fname="%let outputfile="/user/cq_"$1".csv";"

sed "29s/.*/\"$ct_fname\"/" file1.sas > file2.sas

该脚本在第三行失败,我得到了一些关于乱码命令。有谁知道一个聪明的方法来得到这个工作?我怎样才能在引号斜线在 SED

This script fails on the third line, I get something about a garbled command. Does anybody know a clever way to get this to work? How can I get a forward slash in quotes in sed?

推荐答案

您可以使用任何字符代替 / ,所以只挑一个,是不是在 $ ct_fname

You can use any character in place of the /, so just pick one that is not in $ct_fname:

sed "29s|.*|\"$ct_fname\"|" file1.sas > file2.sas

这篇关于在引号SED,向前的斜线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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