shell随机写入指定文件

具体思路如下,求代码
shell随机读取file.txt文本,file.txt文本有许多行文字
想用shell随机读取file.txt的任意一行文字并且写入到file.php第四行文件。

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

shell 排序去重问题


https://segmentfault.com/q/1010000000665713

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压缩包中批量替换某文件脚本

http://seanlook.com/2015/01/29/shell-batch-replace-files-from-rar-zip/
 
 
原文地址:https://www.cnblogs.com/moss_tan_jun/p/5945040.html