当前位置: 首页 > news >正文

做网站php/搜索引擎优化的目标

做网站php,搜索引擎优化的目标,贵州网站推广公司,网络服务广告概述如果大家熟悉java的话,遍历文件夹然后检索相关信息可能比较简单,基本有现成的资料,修修补补就好了。今天主要讲怎么用shell来遍历目标文件夹和所有文件并统计相关信息。需求编写一个shell脚本来查看目标文件夹下所有的file和directory&am…

概述

如果大家熟悉java的话,遍历文件夹然后检索相关信息可能比较简单,基本有现成的资料,修修补补就好了。今天主要讲怎么用shell来遍历目标文件夹和所有文件并统计相关信息。


需求

编写一个shell脚本来查看目标文件夹下所有的file和directory,并且打印出他们的绝对路径。

运行command:./showdir.sh input_path output_result

思路:

BFS遍历,数据结构为queue,数组实现


测试环境准备

[oracle@nwppdb:/home/oracle]$mkdir -p test/test1/test11/test111[oracle@nwppdb:/home/oracle]$mkdir -p test/test2/test22 [oracle@nwppdb:/home/oracle]$echo 123>test/1.txt [oracle@nwppdb:/home/oracle]$echo 123>test/2.txt[oracle@nwppdb:/home/oracle]$echo 123>test/test1/3.txt[oracle@nwppdb:/home/oracle]$echo 123>test/test1/test11/4.txt[oracle@nwppdb:/home/oracle]$echo 123>test/test1/test11/5.txt[oracle@nwppdb:/home/oracle]$echo 123>test/test2/6.txt [oracle@nwppdb:/home/oracle]$echo 123>test/test2/test22/7.txt[oracle@nwppdb:/home/oracle]$echo 123>test/test2/test22/8.txt
94b0991a07449d66d07633c134b1b82b.png

脚本实现:

[oracle@nwppdb:/home/oracle]$cat showdir.sh #!/bin/bashSAVEIFS=$IFSIFS=$(echo -en "b") #处理特殊字符文件名queue[0]="head"path_[0]=''head_index=0 #head = the first inde - 1tail_index=1 #tail=length the last index + 1head="null"dir_count=0file_count=0path=``#if the output directory is not exist, make a new directory#处理目标文件所处地址不存在问题out_path=$2e_path=""while [ ${out_path##*/} != ${out_path%%/*} ]do dir_name=${out_path%%/*} if [ ! -e $e_path""$dir_name ] then  mkdir $e_path""$dir_name fi e_path=$e_path""$dir_name"/" out_path=${out_path#*/}donetouch $2#use queue to take BFSfunction enQueue(){ #insert into tail queue[${tail_index}]=$1 path_[${tail_index}]=$path"/"$1 tail_index=$((${tail_index}+1))}function deQueue(){ #dequeue from head head_index=$((${head_index}+1)) head=${queue[head_index]}}#start of this programenQueue $1while [ ${head_index} -ne $((${tail_index}-1)) ]dodeQueuepath_[1]=`pwd`"/"$1path=${path_[$head_index]}echo "["${head}"]" >>$2for var in `ls ${path_[$head_index]}`doif [ -d $path"/""${var}" ]thendir_count=$((${dir_count}+1))enQueue $varfiecho $path"/""${var}" >>$2file_count=$((${file_count}+1))doneecho "" >>$2donefile_count=$((${file_count}-${dir_count}))echo "[Directories Count]:"${dir_count} >>$2echo "[Files Count]:"$file_count >>$2IFS=$SAVEIFS
e8de06ec96586a995664fc16a1435e17.png
46e8930506b44847211876f64e0aabd6.png

测试脚本

cd /home/oracle./showdir.sh test showdir.md
c7c9ae8a6d7b86a7df8073aa47f5bd53.png

篇幅有限,用shell去遍历的内容就介绍到这了,大家有空也可以自己测试下。

后面会分享更多关于devops和DBA方面内容,感兴趣的朋友可以关注下!!

fc42584df83a637159f36556f681f2e5.gif
http://www.lbrq.cn/news/1575649.html

相关文章:

  • 佛山建站模板/上海专业seo服务公司
  • 正规的网站建设明细报价表/电脑编程培训学校哪家好
  • 四川省住房和城乡建设厅门户网站/哈尔滨网站优化
  • 招标网站建设方案/网络seo哈尔滨
  • 做网站微信朋友圈应该怎么发/企业如何建立网站
  • 为什么我的网站只有新闻业被收录/网络营销活动方案
  • 组建做网站的团队/百度竞价广告收费标准
  • 做毕业论文的网站/淘宝seo 优化软件
  • 网站建设对用户影响/深圳关键词快速排名
  • 营销型网站的建设软文/电脑培训班多少费用
  • 如何把网站做权重/百度投诉电话24小时
  • 怎么做网站demo/软文代理平台
  • 做网站以后的趋势知乎/网络推广产品要给多少钱
  • 北京 网站设计找时代创信好/百度竞价一个月5000够吗
  • 建设网站前端/腾讯会议多少钱一个月
  • 昆明凡科建站/潍坊网站建设咨询
  • 陶瓷网站策划书/网络营销方案如何写
  • 软件工程主要课程/西安seo盐城
  • 公司网站建设计划书/网站排名优化价格
  • wordpress用户后台插件/seo推广具体做什么
  • 快速做网站的技术/宁波网站推广找哪家
  • 河口建设局网站/百度app营销软件
  • a网站建设/百度最新秒收录方法2021
  • app制作和网站一样吗/seo排名哪家有名
  • 新网站前期seo怎么做/品牌网站建设公司
  • 安防公司做网站图片/网站建设报价单模板
  • 做美食教程的网站/2020做seo还有出路吗
  • 做外贸的免费网站有哪些/广州seo服务
  • 做货代的要注册哪种物流网站/数字营销成功案例
  • 网络营销如何进行网站推广/凡科网建站系统源码
  • 三、非线性规划
  • Docker部署 Neo4j 及集成 APOC 插件:安装与配置完整指南(docker-compose)
  • C++QT HTTP与HTTPS的使用方式
  • 每日五个pyecharts可视化图表-line:从入门到精通 (4)
  • 深入剖析 React 合成事件:透过 onClick 看本质
  • Langchain入门:文本摘要