shell编程之for循环-写指定数量的单词到文件
2015-12-31 13:39
726 查看
脚本带2个参数,指定往文件写入多少个单词,和文件的名字。
生成文件后可以用系统自带的命令wc来检验。(wc,word count程序,一般系统已集成)
注意空格与换行符号。
生成文件后可以用系统自带的命令wc来检验。(wc,word count程序,一般系统已集成)
#!/bin/bash #echo "in $#" if [ $# -eq 2 ] then FILE=$2 rm -f $FILE i=1 while [ $i -le $1 ] do echo -n "one " >> $FILE let i=i+1 done echo "I wrote $1 words" wc -w $FILE else echo "Usage: $0 number(such as 500) filename" fi
注意空格与换行符号。
相关文章推荐
- git bash使用指南(markdown版本)
- shell之declare 声明变量类型
- python shell 根据ip 获取 hostname || 根据hostname 获取 ip
- shell 参数
- 常用shell命令实战
- 1066 Bash游戏 分类: 51nod 2015-07-20 22:15 5人阅读 评
- MAC 下的简单 SHELL 入门
- Babun, Great Windows Shell
- HBase 常用Shell命令
- 如何用shell脚本监控服务器负载、cpu、内存、硬盘和登录用户数
- chapter11:认识与学习bash之(2)Bash Shell的操作环境
- chapter11:认识与学习bash之(1)认识shell与shell的变量功能
- shell脚本如何批量备份数据库
- Shell脚本使用TinyPng批量压缩图片
- adb shell 是这个啥东东
- 常用linux shell脚本记录
- ubuntu环境下的用户添加 - 指定用户shell
- shell脚本学习(五)
- shell脚本的一些基础知识
- 使用 adb shell 抓取 Android 性能数据