Shell编程练习
来源:互联网 发布:seo sem 编辑:程序博客网 时间:2024/05/16 23:37
题目:利用所学知识,写一个脚本,实现一下功能:将 uboot 源码中包含的 awk 命令的文件找出来,并将它们拷贝到一个叫 awks 的目录中。
程序一:
#!/bin/bash full_path_files=`grep 'awk' * -wr | awk 'BEGIN{FS=":"} {print $1}' | uniq` bk="awks"if [ ! -d $bk ]then mkdir $bkfi for full_path_file in $full_path_filesdo echo $full_path_file > files file_name=`awk 'BEGIN{FS="/"} {print $NF}' files` if [ -e "$bk/$file_name" ] then n=`ls $bk/$file_name* | wc -w` n=$(($n + 1)) cp $full_path_file $bk/$file_name$n else cp $full_path_file $bk/$file_name fidone
程序二:
#!/bin/bash full_path_files=`grep 'awk' * -wr | awk 'BEGIN{FS=":"} {print $1}' | uniq`bk="awks" if [ ! -d $bk ]then mkdir $bkfi for full_path_file in $full_path_filesdo if [ $full_path_file != collect_awk.sh ] then echo $full_path_file > files file_name=`sed 's/\//#/g' files` cp $full_path_file $bk/$file_name fidone
0 0
- shell编程练习
- Shell编程练习
- shell编程练习001(20160226)
- bash shell 编程练习一
- bash shell 编程练习二
- shell编程的小练习
- Linux SHELL编程练习case1
- shell 编程实例练习(二)
- shell编程练习002(20160227)
- 学习shell——编程练习
- 学习shell——编程练习
- shell脚本编程基础1及练习
- shell脚本编程2及练习
- shell练习
- shell练习
- shell 练习
- shell练习
- shell练习
- 让Linux服务器时间同步
- 组合c(m,n)的计算方法
- 深入浅出AT命令(3)-网络服务命令
- 使用Sublime Text时unable read project问题的解决方法
- java实现简单的单点登录
- Shell编程练习
- 数组名作为函数参数
- USB OTG的工作原理-相互切换和交互流程
- OpenSSL库的RSA使用(下)-rsa函数方式
- 12.10 公司面试总结
- 程序员必知(六):信息论问题
- (转)LLVM IR 简介
- 软件开发经济实用的15条实践
- IPv6的一些特殊地址