小编Rcz*_*one的帖子

在Unix shell中反转一个文件

我有一个文件parse.txt

parse.txt包含以下内容

remo/hello/1.0,remo/hello2/2.0,remo/hello3/3.0,whitney/hello/1.0,julie/hello/2.0,julie/hello/3.0
Run Code Online (Sandbox Code Playgroud)

我想使用parse.txt将output.txt文件作为(从最后一个到第一个的顺序)

julie/hello/3.0,julie/hello/2.0,whitney/hello/1.0,remo/hello3/3.0,remo/hello2/2.0,remo/hello/1.0
Run Code Online (Sandbox Code Playgroud)

我试过以下代码:

tail -r parse.txt 
Run Code Online (Sandbox Code Playgroud)

unix bash shell

12
推荐指数
4
解决办法
2130
查看次数

删除文本文件中的连续重复逗号

我有一个文本文件名file.txt包含

remo/hello/1.0,remo/hello2/2.0,,remo/hello3/3.0,whitney/hello/1.0,,,julie/hello/2.0,,,,remo/hello2/2.0,,remo/hello3/3.0,,
Run Code Online (Sandbox Code Playgroud)

我想删除文件中连续的重复逗号(,),删除输出文件后应该是这样的

output.txt的

remo/hello/1.0,remo/hello2/2.0,remo/hello3/3.0,whitney/hello/1.0,julie/hello/2.0,remo/hello2/2.0,remo/hello3/3.0,
Run Code Online (Sandbox Code Playgroud)

我试过下面的代码:

awk '!seen[$0]++' filename
Run Code Online (Sandbox Code Playgroud)

但没有成功.

请帮助TIA.

bash shell awk sed

1
推荐指数
1
解决办法
578
查看次数

grep值并重新排列文件

嗨我有一个文件名test.txt

    (standard input):8:      <property name="ProcedureName" value="abc"/>
(standard input):7:         <property name="PackageName" value="123abc"/>
(standard input):8:         <property name="ProcedureName" value="bac"/>
(standard input):7:      <property name="PackageName" value="bac123"/>
(standard input):8:      <property name="ProcedureName" value="cde"/>
(standard input):7:      <property name="PackageName" value="cd123"/>
(standard input):8:      <property name="ProcedureName" value="b4u"/>
(standard input):7:      <property name="PackageName" value="b4u234"/>
Run Code Online (Sandbox Code Playgroud)

我必须以下面的格式从此文件中仅grep packagename和procdeurename的值:进入o/p文件

abc/123abc
bac/bac123
cde/cd123
b4u/b4u234
Run Code Online (Sandbox Code Playgroud)

尝试削减和awk但无法得到

shell awk grep cut sed

-2
推荐指数
1
解决办法
74
查看次数

标签 统计

shell ×3

awk ×2

bash ×2

sed ×2

cut ×1

grep ×1

unix ×1