- 浏览: 38216 次
- 性别:
- 来自: 南京
最新评论
文章列表
function check_space()
{
local check_dir=$1
local need_space=$2
local avail=$(df -B1m $check_dir | sed -n '$p' | awk '{print $(NF-2)}')
[ $avail -le $need_space ] && \
die "not enough space in ${check_dir} (need:${need_space}M available:${avail}M)"
}
------- ...
#!/bin/bash
files=(`ls -1`)
for file in ${files[@]}
do
if [ $file = "my.sh" ];then
continue
fi
filelen=`expr length $file`
typeset leftlen=`expr $filelen - 5`
typeset leftFile=`echo $file |awk '{print substr($0,1,'$leftlen')}'`
echo "leftF ...
//未定义变量,操作报异常
try:
li
if len(li) == 0:
print 'ok'
except:
print 'fail'
-------------------------------------------------------------------------------------------
//输出格式
k = "uid"
v = "sa"
print "%s=%s" % (k,v)
----------------------------------------- ...
模块导入:
xx.py
def getName():
return "xuxu"
yy.py
//调用方法与java的类调用相同
import xx
ret = xx.getName()
print ret
-------------------------------------------------------------------------------------------
def testList():
typeList = []
typeList.append("a")
ret ...
#!/bin/bash
#while为真的另一种用法
while ; #等价于:while true; true为关键字
do
echo "ok"
break
done
-------------------------------------------------------------------------------------------
//比较运算的另一种方式[[]]
#!/bin/bash
typeset -i count=1
if [[ 1 < 2 ]];then
count=`expr $count+1 ...
echo "drop user testads cascade;
drop tablespace testads including contents and datafiles;
exit" | sqlplus 'system/system'@ttdemo
sqlplus system/system@lbs "@test.sql"
等于:
echo "@test.sql" | slqplus sytem/system@lbs
----------------------------------------- ...
package tool;
import java.util.HashMap;
import java.util.Map;
/**
* 将两个数组的值合并为一个Map,如果值重复,则相加
*
*/
public class MergeArray
{
public static void main(String[] args)
{
String[] strArray =
{ "a", "b", "c", "a", "b" };
String[ ...
#!/bin/bash
#set -x
typeset logfile=kill.log
typeset -i count=0
typeset user=`whoami`
typeset -a PIDS
function doKill
{
while :
do
p1=`ps -fu $user |grep 'httpPort=' | grep -v 'grep' | awk '{print $2}'`
p2=`ps -fu $user |grep 'tee' | grep -v 'grep' | awk '{print $2}'`
p3=`p ...
//在crud中调用函数
select Func_getUTCDate() from dual;
------------------------------------------------------------------------------------------
//oracle的分页
select * from (select t. * , rownum as linenum from t_person t where ro ...
test 字符串比较命令:
-n str1 str1 is not null (has length greater than 0) 不为空并且长度大于0
-z str1 str1 is null (has length 0) 为空或者长度为0
更细致的文档推荐在字符串比较时尽量不要使用 -n ,而用 ! -z 来代替。(其中符号 "!" 表示求反操作)
//对于字符串的比较,最好使用[[]]运算符
#!/bin/bash
if [[ "abc" ...
-------------------------------------------------------------------------------------------
内建命令,即bash内置的命令
#!/bin/bash
cd()
{
echo 'ok'
}
cd
echo 'now buitin'
builtin cd
-------------------------------------------------------------------------------------------
echo ${UID}_
...
//只输出符合规则的字符串
grep -o太重要了!!
AIC2 ftp1204/.dd> echo 'abbc' | grep -o 'b'
b
b
实现功能:
将text.txt文件中的${内容}中的内容取出来
#!/bin/bash
{
while read line
do
echo $line | grep -o '${.[^${}]*}' | sed -e 's/\${//g' | sed -e 's/}//g'
done
} < text.txt
---------------------------- ...
-------------------------------------------------------------------------------------------
for用法:
//常用的方式如下
#!/bin/bash
for (( i=0;i<3;i++ ))
do
echo $i
done
//如果写成 for day 而没有后面的 in [list] 部分,则 day 将取遍命令行的所有参数。如这个程序:
#!/bin/bash
for param
do
echo $param
done
exit 0 ...
-------------------------------------------------------------------------------------------
shift关键字
#!/bin/bash
fun()
{
echo $1
shift
echo $1
}
fun a b c
-------------------------------------------------------------------------------------------
function wrap
{
#set - ...
-------------------------------------------------------------------------------------------
$0: 脚本中时,代表执行文件的名字,注意不包含参数
$0: 命令行时,代表当前shell的名字
$0: awk时,代表当前的一整行
--------------------------------------------------------------------------------------------
在Vim 中可以直接查看文件编码
:set fileencoding
: ...