随笔分类 -  Linux Shell

Linux 面试常用总结
摘要:文件显示1. cat:可以显示文件的内容(经常和more搭配使用),或将多个文件合并成一个文件。cat /etc/hosts | more2. head/tail -n 10cat /etc/hosts | head -n 10 或 head -n 10 /etc/hosts3. grep -v反选/支持数据重定向输入/支持正则表达式cat /etc/hosts | grep -n 'require' 显示包含require的行cat /etc/hosts | grep -v 'require' 显示不包含require的行cat /etc/hosts | gr 阅读全文
posted @ 2013-08-07 02:45 doclaim 阅读(418) 评论(0) 推荐(0)
linux 循环判断、数组、循环
摘要:通过一个循环展示数组、循环、Case条件判断结构#/bin/bashif [ $# == 0 ];then echo "please input the name" exit 1fiparm1=$1#存入数组for((i=0;i<=${#parm1};i++))doarr[$i]=${parm1:$i:1}done#循环显示数组元素for((i=0;i<=${#arr[@]};i++))do echo ${arr[$i]}done#循环显示数组元素的另一种写法for n in ${arr[*]}do echo $ndone#循环用while的方式declare 阅读全文
posted @ 2013-06-17 01:59 doclaim 阅读(1068) 评论(0) 推荐(0)
shell与sqlplus交互
摘要:sqlplus 常用参数-s: 不显示登录时的头信息,也不显示提示符,一般用在shell中调用sqlplus时set heading off: 不显示列名set feedback off: 不显示行数信息最基本的shell中调用sqlplus格式<< EOF ....... EOF: EOF是一对标识符,标识其内的文字传给左右的的命信,不一定必须是EOF 可以是任何两个对应的字符#!/bin/bashsqlplus /nolog << EOFconn scott/tigerselect * from dept;exitEOF[oracle@localhost test] 阅读全文
posted @ 2013-06-09 01:29 doclaim 阅读(1023) 评论(0) 推荐(0)
linux 数组与循环结构
摘要:数组定义与赋值静态arr=(1,2,3) #三个元素分别为1,2,3的数组,等同于下面arr[0]=1arr[1]=2arr[1]=3清空单个元素arr[n]=清空整个数组arr= 或 unset arr动态for((i=0;i<=3;i++))do arr[$i]=$idone数组读取单个var=${#arr[1]}循环for((i=0;i<=${#arr[*]};i++))do echo ${#arr[$i]}donedeclare -i s=0declare -i count=${#arr[*]}while [ $s -le $count ]do echo ${#arr[$s 阅读全文
posted @ 2013-06-06 14:41 doclaim 阅读(305) 评论(0) 推荐(0)
linux shell 基本语法
摘要:一、数值相关1.1、数值运算符个人理解便于记忆-eqequals-nenot equals-ltlittle-gtgreat-lelittle equals-gegreat equals1.2、整数比较逻辑表达式 置于[ ]或[[ ]]中,可用上表的运算符,也可用字符类的运算符如=、 >=等 表达式及运算符两边都要有空格 正确:[ 2 = 2 ]、[ 2 –eq 2 ]、[[ 2 –eq 2 ]] 错误:[2 = 2]、[ 2=2]1.3、变量定义与赋值 A、 declare –i varname 如 de... 阅读全文
posted @ 2013-06-04 19:23 doclaim 阅读(237) 评论(0) 推荐(0)