在脚步lookup中,询问用户是否要往文件datafile添加一条记录
2012-06-21 16:40
363 查看
![](http://my.csdn.net/uploads/201206/21/1340268135_3438.png)
答:
1 #!/bin/bash
2 #
3 #######################################
4 # Script name: lookup.bash
5 # Actor: Hua Jielong
6 # Date: 2012-06-20
7 # Script purpose: do for test
8 #######################################
9 #
10 if (( $# != 1 ))
11 then
12 echo "Usage:./lookup.bash $1" >&2
13 exit
14 fi
15
16 if [ ! -e $1 ]
17 then
18 touch $1
19 chmod +rw $1
20 fi
21
22 if [ ! -w $1 ]
23 then
24 chmod +rw $1
25 fi
26
27 if [ ! -s $1 ]
28 then
29 echo "-----$1 is a empty file-----" >&2
30 fi
31
32 echo "Do you need add new record to $1, yes or no?"
33 read answer
34
35 if [[ $answer = "yes" || $answer = "y" ]]
36 then
37 echo "Please input name tel addr birthday salary!"
38
39 echo -n "input name>"
40 read name
41
42 echo -n "input tel>"
43 read tel
44
46 echo -n "input addr>"
47 read addr
48
49 echo -n "input birthday>"
50 read birthday
51
52 echo -n "input salary>"
53 read salary
54
55 echo "$name:$tel:$addr:$birthday:$salary">>$1
56
57 cat $1|while read line
58 do
59 echo "$line"
60 done|sort -n>>tmp$$
61 mv $1 $1.bak
62 mv tmp$$ $1
63 chmod 777 $1
64
65 record=`grep -n -w $name:$tel $1`
66 echo "$record"
67 fi
相关文章推荐
- Python---购物车更新程序 商品信息存在文件当中,用户购买记录要打印已购商品,余额。卖家可以添加商品,修改价格。
- 动态:添加表空间定义文件出错不能添加第2个文件 innodb_data_file_path = /data1/ibdata1:10M:autoextend;/data1/ibdata2:1000M:autoextend
- 将字符串添加到指定的文件中去 AppendAllText ;WriteAllText ;----------------判断指定路径的文件是否存在File.Exists(Path)
- oracle数据库之删除数据文件[物理地删除一个数据文件但它的信息仍然记录在数据字典v$datafile中]
- ajax判断用户是否可以增加一条记录
- 通过Dockerfile 文件为linux images 添加新用户
- 判断XML文件是否存在,不存在就创建一个XMl文件,存在就在里面添加一条数据
- 添加文件【COCOS2DX-LUA 脚本开发之十三】解决lua项目编译Android出现get data from file failed、Cocos2dxActivity cannot be 路径等问题
- 解决办法:异地冷恢复时 如果发现v$datafile里的有些用户用的数据文件没有备份
- 通过Dockerfile 文件为linux images 添加新用户
- 把整个文件作为一条记录处理 WholeFileInputFomrat
- fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h
- 【转】搜索引擎会通过日志文件把用户每次检索使用的所有检索串都记录下来,每个查询串的长度为1-255字节
- fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h
- mysql判断一条记录是否存在,如果存在,则更新此语句,如果不存在,则插入
- fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h
- [html file]标签设置用户不能自己手动输入文件路径
- 错误:在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加"#include"stdafx.h""
- asp.net文件上传用到html的file控件,在使用母版页Master,更改form的Enctype=multipart/form-data的方法
- vs2010:fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "StdAfx.h"”?