Home > Backend Development > PHP Tutorial > shell随机写入指定文件

shell随机写入指定文件

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:45:28
Original
1119 people have browsed it

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

回复内容:

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

假设你的 file.txt 里没有特殊字符:

sed -i -e "4s/.*/$(sort -R file.txt | head -1)/" file.php
Copy after login
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template