具体思路如下,求代码

shell随机读取file.txt文本,file.txt文本有许多行文字

想用shell随机读取file.txt的任意一行文字并且写入到file.php第四行文件。


sed -i -e "4s/.*/$(sort -R file.txt | head -1)/" file.php

​​shell 排序去重问题​​

javascript:void(0)

​​shell的touch命令不能拼接路径吗​​

export mypath=/tmp export subpath=/1 echo "$mypath$subpath/filename.txt"


文件为:

a|+|123|+|0|+|-|

b|+|222|+|1|+|-|

c|+|222|+|0|+|-|

a|+|123|+|0|+|-|

a|+|123|+|0|+|-|

c|+|222|+|0|+|-|

根据第一个域和第二个域排重,并把重复的记录写入临时文件

a|+|123|+|0|+|-|

a|+|123|+|0|+|-|

a|+|123|+|0|+|-|

c|+|222|+|0|+|-|

c|+|222|+|0|+|-|



​sort test.txt -k1,2 | uniq -d > repeat.txt​​前面是对文件进行排序,后面是去重并将有重复的行重定向到repeat.txt文件中


Linux下rar及zip压缩包中批量替换某文件脚本