在每一行上将一个值替换为另一个值
Replace one value with another on each line
给出以下示例文本行(从一个大文件中提取):<document id ='3316200'srcDocId ='http://ecx.images-amazon.com/images/I/61A9A0fmN7L.jpg'</ document> <文件......
find和sed在centos 7中不起作用
find and sed doesn't work in centos 7
我正在尝试在我的整个项目中找到并替换一个单词,我尝试了以下版本的find和sed in centos 7但没有任何作用。 find ./ -name“* .php”-exec sed -i's / mysql_ / mysqli_ / g \; 找 。/...
Sed bug会导致最后一行从文件输出流中丢失?
Sed bug causes last line to be lost from file output stream?
全部,我有一个非常简单的Sed命令,如下所示sed s / XXXX / TestValue / >> new.xml <template.xml我在发送之前使用Sed编辑模板XML文件。 输入文件>> template.xml ...
是否可以解析标准错误而无需先写入文件?
Is it possible to parse standard error without writing out to a file first?
在一个简单的例子中,假设我们有一些标准错误:$ ls / fake / file ls:/ fake / file:没有这样的文件或目录问题:是否可以从标准错误中解析出“/ fake / file”而无需...
如何从文件中添加几行到另一个文件的开头?
How to Add few lines from a file to the beginning of another?
我使用sed从文件中提取前69行。 sed -n'1,69p'file.vcf> header.vcf如何将它放在另一个文件的开头(Fist行)?
grep一个单词,如果匹配则获取括号之间的内容
grep for a word and if it matches get the content between parentheses
我有很多文件,通常如下所示。 {key1:value1,key2:value4},{key1:value1,key2:value4},{key3:value3,...
仅在包含其他关键字的行中更改文件中的关键字
Change keyword in a file only in the lines that contain another keyword
我的文件行以两个可能的关键字ATOM和HETATM开头。 在其中一些行中,有一个第二个关键字HOH,出现在其他一些字符之后。 在其他方面,有......
与sed匹配后,我能获得下一行的长度吗?
Can I get the length of the next line after match with sed?
我有一个序列文件,格式化为一行信息后跟序列,例如:someinformation length = 50 JJJIJJJJJJJJJJJJJJJJHHHHHFFFFFCCC someotherinformation length = ...
sed - 用点替换是对的还是我应该逃脱它?
sed - is this replacement with a dot is right or should I escape it?
sed -i''-e's / firstdomain.com / seconddomain.com / g'我应该逃避点吗? 如果是这样我怎么能这样做?
awk:逐行读取文件,sed从列解析IP
awk: read file line by line and sed to parse IP from column
我有一个问题,使用awk和sed来解析日志文件。 以下文件:DDDD; callID:4565; AAAA;正文:测试消息1; BBBB; ng?10.1.5.60 4565;完整DDDD; callID:5489; AAAA;正文:测试消息2; BBBB; ng?10 ... 。
LINUX-我的代码在sed中出了什么问题?
LINUX- What is wrong with my code in sed?
我想用ExecStart = / sbin替换ExecStart = / sbin / runuser -l <USER> -c“/ usr / bin / vncserver%i”PIDFile = / home / <USER> /。vnc /%H%i.pid / runuser -l root -c“/ usr / bin / vncserver%i”...
如何从子文件中读取数据并使用linux将其附加到父文件的末尾
how to read data from daughter files and append it to the end of parent file using linux
我有100个子文件具有相同的扩展名,如thin1.txt thin2.txt thin3.txt。 。 。 。 。 。 。 。 。 每个文件包含一个像0.99456的数字我想将这些文件的所有数字追加到...
shell bash全局替换文件
shell bash global replace on a file
我想知道如何在文件上进行全局替换,基本上,我有一个包含多个属性的文件,我循环遍历此文件创建一个数组来存储每个propety值。 财产......
打印包含1列中2个字符且另一列中包含模式匹配的CSV行
Printing lines of a CSV containing 2 characters in 1 column and a pattern match in another column
我有一个4列的CSV文件:01,猫,动物,它捕获老鼠该文件包含UTF-8中各种语言的许多字符。 如何在...中仅打印包含2个字符的那些行?
shell bash,cat文件,同时使用sed替换文本
shell bash, cat file whilst using sed to replace text
在SO的帮助下,我已经能够纠正我的sed命令,因此我可以使用变量(使用'代替'而不是使用g代表全局)。但是,我正在努力让命令工作......
如何用sed搜索和替换这个字符串?
How to search and replace this string with sed?
我拼命想要搜索以下内容:<texit info> author = MySelf title = MyTitle </ texit>并将其替换为空白。 到目前为止我所尝试的是:sed -I'1,5s / <...
找到文件中的条目数,并使用shell脚本删除这些条目
find the number of entries in a file and remove those enties using a shell script
我有以下代码,我从我的系统收集了大于40k的所有文件大小。 我已将所有这些信息存储到文本文件中。 我需要处理文件来读取...的数量
Bash - 查找带空格的文件并使用sed [duplicate]重命名
Bash - finding files with spaces and rename with sed
我一直在尝试编写一个脚本来重命名包含空格的所有文件,并用短划线替换空格。 示例:“Hey Bob.txt”到“Hey-Bob.txt”当我使用for循环时,它只是拆分了......
在远程计算机上查找文件
find files on remote machine
您好我正在尝试在远程计算机上执行以下命令如何执行此操作ssh login.com find / nfs / repo / -name“.user_repo.log”| \ xargs cat | awk'{$ NF =“”; 打印$ 0}'| \ ...
在两个逗号之间抓取数据
Grabbing data between two commas
我正在编写一个简单的脚本来从acpi中获取电池信息,因此我可以格式化并输出它。 目前,我正在使用cut获取此信息,但作为电池状态......
用包含特殊字符的长字符串(每次都有变化)替换文本
Substitute a text with long string (which varies every time) that contains special characters
查找并替换文件中的文本。 查找单词一直是相同的,并且替换字符串一直在变化我尝试使用一个简单的sed脚本(test.sh)来实现这个使用参数(长...
如何使用linux中的inplace editing sed替换包含字符串与来自另一个文件的数字的行上的特定记录
how to replace specific record on a line containg a string with a number from another file using inplace editing sed in linux
我有一个像下面这样的输入文件。 R sfst 1000.0000 $大规模计算的新时间步骤R dt2ms -4.000E-7 ...
sed从角色中移除角色
sed to remove from a character to a character
我有一些如下的数据。 <some-thing> my-data <some-thing>我想搜索一个字符'<'并删除到'>'并需要输出如下。 我的数据有没有......
sed语句语法错误?
sed statement syntax wrong?
我的sed仅在输入文件的最后一个条目是'in'时有效,如果文件有'in'或'out',我怎么能让它工作? 我尝试了不同的变化而没有成功。 egrep -w'TCP | UDP'denden.txt | sed's /:[...
在终端的每一行的开头插入来自filename的更改字符串
Insert changing string from filename at the beginning of every line in terminal
我对bash没有经验,所以我在语法上挣扎 - 我放弃了在python中尝试,因为我认为它可能更容易。 我想提取部分文件名(在.xyz之前...
Unix查找并替换所有条件
Unix find and replace all with a condition
我有一个条件,我想在一个文件中找到并替换所有具有特定条目的行'/'(前/后有空格)。 示例如下:g aaa / cccc dd k eee / hhhh dd m ...
如何迭代两组数据?
how to iterate over two sets of data?
我正在尝试创建自己的程序来执行递归列表:每行对应于单个文件的完整路径。 我现在正在研究的棘手部分是:我不希望绑定坐骑欺骗我......
使用sed / bash删除左右方括号
Remove Left and right square brackets using sed/bash
我有一个带有此角色的文件[贡献者]。 即贡献者和盲文,我需要使用下面的代码将其删除:找到。 -type f -exec sed -i's @ [Contributor] @@ g'{} + ...
如何使用bash shell中的section读取配置文件
How to read config files with section in bash shell
我有这样的配置文件[rsync_includes]用户数据conf [rsync_exclude] tmp .pyc * / vendor [javascript] utils数据我有我想要在rsync中排除的模式...
组合CSV文件并通过AIX awk,sed,ksh将一些列连接成单列
Combine CSV files and concatenate some columns into single column via AIX awk, sed, ksh
我有多个这样的文件:File_1.csv:“Job Id”,“Batch Id”,“Id”,“Success”,“Created”,“Error”,“Col1”,“Col2”,“Col3”aaabbb111, xxxyyy999,“false”,“false”,“Horrible_Error:发生了真正错误的错误:......
在Mac命令行上使用sed时无法替换换行符
Cannot replace with newlines when using sed on Mac command line
我有一个curl API响应,当我得到响应时,我无法用\ n替换<br>。 当我尝试这个时,它会在文本中输出一个文字n。 我正在做的是沿着...的卷曲命令
涉及echo,python脚本,grep,sed,bc和date的bash脚本中的间歇语法错误
Intermittent syntax error in a bash script involving echo, a python script, grep, sed, bc, and date
我编写了一个python脚本来从Raspberry Pi Astro“Sense Hat”传感器进行磁场测量。 它被称为“mag-AstroPi.py”:#!/ usr / bin / python来自sense_hat import SenseHat sense = ...
使用sed命令替换文件中的2行
Replace 2 lines in a file using sed command
我尝试删除倒数第二行的逗号:{“subject”:{“value”:“http://d-nb.info/gnd/1-2”,“type”:“uri” },“谓词”:{“value”:“http://www.w3.org/1999/02/22 -...
根据模式替换两个连续的行并重复整个文件
replace two consecutive lines based on a pattern and repeat through out the file
我正在尝试根据模式匹配替换两个连续的行,并希望重复整个文件。 这是输入文件:c aaaaa bbb + 0.1 c xxxx c yyyy + 0.2 * c gggg m eeeee ...
Perl - 使用sed或tail来内联文件的第一行并将第一行返回到var
Perl - using sed or tail to remove first line of a file inline and return 1st line to a var
这对我来说很新,但是,我正在慢慢接受它。 我需要打开一个文件,将第一行返回到var来做东西,然后在东西成功后从文件中删除第一行。 在mt脚本中,这里......
awk regex magic(匹配每行中第一次出现的字符)
awk regex magic (match first occurrence of character in each line)
一直在摸着这个,希望有一个我错过的简单解决方案。 总结简化以下代码无法处理(这里缩写)apache中的IPv6地址...
在bash中替换完全字符串
Replace exact string in bash
我有一个如下所示的列表:server server.apple.com server.apple.com server server.apple.com现在,我想将“.apple.com”添加到只显示“server”的行中。 我试过sed:...
如何将fasta文件中的序列(几行)重新格式化为单行?
how can I reformat sequences (several lines) in a fasta file to single line?
输入“file.fasta”(注意,这是一个示例....在fasta文件中,序列可能有三行以上)> chr1:117223140-117223856标签:GTGGG GTGGgggggcgCATAGCAGCAGCAGCAGCAGCAGCAGCAGCAGCAGCAGAGtt ...
从文本文件中弹出grep并编辑
Bash grep from text file and edit
我正在对文件test.txt进行更新,该文件存储了一些关于故事书的信息,我在下面的代码中使用了函数,但我意识到使用这种grep方法,我无法得到其余的...
将秒转换为hh:mm:ss格式(或Excel或LibreOffice喜欢的任何格式)并将其插回Bash中的csv文件
Convert seconds to hh:mm:ss format (or whatever format Excel or LibreOffice likes) and insert it back to a csv file in Bash
我有一个像这样的csv文件:ELAPSEDTIME_SEC; CPU _%; RSS_KBYTES 0; 3.4; 420012 1; 3.4; 420012 2; 3.4; 420012 3; 3.4; 420012 4; 3.4; 420012 5; 3.4; 420012我想要在...中转换值(它们是秒)
如何在sed中更改日期格式?
How to change date format in sed?
假设我想通过date命令将时间戳中的日期转换为另一种格式。 在控制台中我会说日期-d @ <timestamp>但我碰巧想要对文本文件中的许多字段执行此操作。 ...
通过SED awk在文件中的特定位置插入一个字符串
insert a string at specific position in a file by SED awk
我有一个字符串,我需要插入文件中的特定位置:该文件包含多个分号(;)我需要在最后一个“;”之前插入字符串 这可能与SED有关吗? ...
在linux中的特定匹配后将列值转换为行
convert column values to row after particular match in linux
我有一个文件,其中值在重复模式下都在1列中(1组值在10行之后)。 现在我想在重复模式中将这组值从列到行(设置为明智)。 ...
SED命令在替换字符串时给出错误
SED command giving error while replacing a string
我需要用文件中的另一个字符串替换字符串。 我有下面一行文件。 tibco.env.LD_LIBRARY_PATH%TPCL_HOME%/ lib / httpclient_3.0:%TPC L_HOME%/ lib:%RV_HOME%/ lib:%TRA_HOME%/ icjava / 6.2 / ...
shell:替换文件中Line的一部分
shell: Replacing a part of Line in a file
我是shell编程新手,不得不做以下任务。 我在第28行(静态)有一个带有以下行的文件。 page.sysauth =“Admin”我想用shell替换这一行...
将每个匹配的字符串替换为以模式开头的每一行中的另一个字符串
Replace every matching string by another one in every line beginning with a pattern
上下文包含需要更新的代码的大型ruby项目。 由于匹配结果的数量很重要,我想进行大规模搜索并用正则表达式替换。 给出的问题......
sed regex查找和替换(awk解决方案欢迎)
sed regex find & replace (awk solutions welcome)
我正在处理一个JSON文件(对于MongoDB),需要将字段名称转换为Database Reference。 我试图通过sed(虽然我对使用awk的解决方案等开放),但我是一个完整的菜鸟......
sed在匹配单个行字符串后附加多行字符串
sed append multi-line string after matching a single line string
如果可能的话,我想用sed来解决这个问题。 这是我的情况:我有一个多线字符串,将通过外部方式给出sed - 可能是puppet shell exec或bash脚本。 字符串......
在正则表达式匹配之间切割输出的最有效方法是什么?
Most efficient way to cut an output between regex matches?
我正在尝试解析每个设备的lspci -k输出。 换句话说,使用此示例输出:00:00.0主机桥:Intel公司第四代核心处理器DRAM控制器(rev 06)...
Bash脚本从一行复制并用副本替换另一行
Bash script to copy from one line and replace another line with the copy
我正在寻找一个bash脚本,比起通常的find / replace通过sed稍微复杂一些。 我有一本名为bash Cookbook的书,我一直试图收集一些灵感......