shell script command example

巴扎黑
巴扎黑Original
2017-07-21 09:17:181237browse

1. Rename the file

Rename A.txt in drive D to B.txt

mv D:\\A.txt D:\\B.txt

2. Delete the file

Delete the A.txt file under the D drive

rm D:\\A.txt

3. Modify the file content and Save

//Get the content of A.txt in drive D

oldtime=$(cat D:\\A.txt)

//Get the current year, month and day
time=$(date +"%Y%m%d")

Replace the content of the A.txt file under the D drive with the current date and save it to the B.txt file under the D drive

sed s/$oldtime/$time/ D:\\A.txt >D:\\B.txt

This article is an essay record

The above is the detailed content of shell script command example. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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