linux 目錄下文件批量植入和刪除,按日期打包


linux目錄下文件批量植入

[root@greymouster http2]# find /usr/local/http2/htdocs/ -type f|xargs sed -i "1  i <script>alert(1)</script>"

其中上面的1 為文件的第一行 i為植入

批量刪除:

[root@greymouster ~]# find /usr/local/http2/htdocs/ -type f|xargs sed -i '/<script>alert(1)<\/script>/d'

[root@greymouster htdocs]# find /usr/local/http2/htdocs/ -type f -exec sed -i "/<script>alert(1)<\/script>/d" {} \;

 批量替換

[root@greymouster ~]# find /usr/local/http2/htdocs/ -type f|xargs sed -i 's#<script>alert(1)</script>#1111#g

 

打印三天前的日期格式

[root@greymouster htdocs]# date +%F -d "3 day ago" 

[root@greymouster htdocs]# date +%F --date "3 day ago"

[root@greymouster htdocs]# date +%F -d "-3 day"

打印明天的日期格式

[root@greymouster htdocs]# date +%F -d "next day"

打印三天后的日期格式

[root@greymouster htdocs]# date +%F -d "+3 day"

注:-d  相當於 --date 

六分鍾前的時間格式

[root@greymouster htdocs]# date +%Y%m%d%H%M -d '-6 min'

 

按日期格式打包

[root@greymouster htdocs]# tar zcvf text-$(date +%F -d '-3 day').tar.gz ./a.php
./a.php
[root@greymouster htdocs]# ls
a.php index.html index.php text-2016-12-18.tar.gz

 

把文件中的空行過濾掉

grep方法

[root@greymouster htdocs]# grep -v "^$"   a.text

sed 方法

[root@greymouster htdocs]# sed '/^$/d'    a.text

awk 方法

[root@greymouster htdocs]# awk /^[^$]/   a.text

把文件中的空行刪除

[root@greymouster htdocs]# find a.text|xargs sed -i '/^$/d' 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM