博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何在Linux上的Bash shell脚本的每一行的开头添加前缀字符串?
阅读量:2516 次
发布时间:2019-05-11

本文共 571 字,大约阅读时间需要 1 分钟。

How to add a prefix at the beginning of each line in Bash script on ?

如何在上的Bash 脚本的每一行的开头添加前缀 ?

For example, assume we have a file a.txt:

例如,假设我们有一个文件a.txt:

line 1line 2

I want to have,

我希望有,

pre line 1pre line 2

You may use , the stream editor for filtering and transforming text:

您可以使用 (流编辑器)来过滤和转换文本:

sed -e 's/^/pre /'

For example,

例如,

$ echo "line 1line 2" | sed -e 's/^/pre /'pre line 1pre line 2

You may also do prefix adding to lines of certain patterns. But this is out of this question.

您也可以在某些模式的行上添加前缀。 但这是不可能的。

Answered by Eric Z Ma.
埃里克·马(Eric Z Ma)回答。

翻译自:

转载地址:http://tfowd.baihongyu.com/

你可能感兴趣的文章
.NET 常用加密、解密& 数字签名算法
查看>>
开博声明
查看>>
FileReader读取文件
查看>>
逆向-攻防世界-re2-cpp-is-awesome
查看>>
Oracle分割字符串 REGEXP_SUBSTR用法
查看>>
O/R Mapping实际开发经验之谈(转)
查看>>
今天才知道原来我还没弄清楚js中全局变量和局部变量的定义...
查看>>
用户心理特征
查看>>
【z05】聪明的质检员
查看>>
【5001】n皇后问题
查看>>
【codeforces 796D】Police Stations
查看>>
数据库事务与锁详解
查看>>
linux 配置ssh免密码登录
查看>>
《重构》的读后感
查看>>
MySQL索引分析和优化
查看>>
DB2中通用的存储进程分页法度典范
查看>>
Fetchmail 6.3.8
查看>>
俄罗斯邮政将迁移到Linux 有关机构已末尾测试Linux
查看>>
SunOS 4上MySQL详尽事变
查看>>
python升级后pip 不可用 卸载pip
查看>>