unix
文章平均质量分 52
调皮的芋头
我是一个非常勤奋、自信的人。
GitHub:https://github.com/liuyu520
展开
-
判断指定目录是否有文件
linux 中如何判断指定目录下是否有文件(包括隐藏文件和符号链接)呢?脚本名:decide_blank_folder.sh脚本内容:#!/bin/sh# whether the specified folder has files,including symbolic file and hidden fileis_blank_dir_yes=2is_blank_dir_...2013-03-21 16:52:50 · 403 阅读 · 0 评论 -
htc t528d解锁
一、官方解锁1).进入点此直达(HTC官方解锁网站http://www.htcdev.com/bootloader/)2).注册 (此处需要用英文填写,中文无法注册) 填写完成后,点击下方的绿色按钮 Register 提交注册信息 正确填写注册信息提交注册后,会提示注册已经成功,并且需要您前往注册邮箱收取激活邮件激活注册! 3).前往您的注册邮箱查看激活邮件...2013-09-05 16:29:20 · 202 阅读 · 0 评论 -
linux shell 遍历指定目录下的所有文件夹
在linux 中,如何遍历指定目录下的所有文件夹呢?要求能搜索结果中包含隐藏文件夹脚本名:ergodic_folder.sh脚本内容:#!/bin/shlist_alldir(){ for file2 in `ls -a $1` do if [ x"$file2" != x"." -a x"$file2" != x".." ];the...2013-01-08 14:47:02 · 940 阅读 · 0 评论 -
linux 获取文件权限
linux 中如何获取文件或文件夹的权限呢?ls -ld /home/ |awk '{print $1}'|sed 's/^[a-zA-Z-]//'rwxr-xr-x[root@localhostarray_study]# echo "obase=8;ibase=2;`ls -ld /home/ |awk '{print $1}'|sed's/^[a-zA-Z-]...2012-11-30 09:40:36 · 1511 阅读 · 0 评论 -
linux 如何判断当前用户
linux 中,如何判断当前用户是否是root 呢?判断当前用户是否是root#---------------------------- root user check ---------------------start if [ `id -u` -ne 0 ]; then echo "Please re-run ${this_file} as r...2012-11-29 15:16:15 · 169 阅读 · 0 评论 -
linux sed 常用用法举例01
判断是否以. 开头echo .abc |grep "^\." ;echo $? 判断是否以/ 开头echo /abc |grep "^/" ;echo $? 判断是否以\ 开头echo "\abc" |grep "^\\\\" ;echo $? sed 多次修改两种方式:可以使用...原创 2012-11-16 11:39:43 · 154 阅读 · 0 评论 -
linux 在shell脚本中获取该脚本的所在绝对路径2
脚本名:a.sh位置:/tmp/whuang/study/java脚本内容:this_dir=`pwd`file_name=`basename $0`dirname $0|grep "^/" >/dev/nullif [ $? -eq 0 ];then this_dir=`dirname $0`else dirname ...原创 2012-11-16 11:31:07 · 119 阅读 · 0 评论 -
linux 在shell脚本中获取该脚本的所在绝对路径
脚本名:a.sh位置:/tmp/whuang/study/java脚本内容: #!/bin/shthis_dir=`pwd`dirname $0|grep "^/" >/dev/nullif [ $? -eq 0 ];then this_dir=`dirname $0`else dirname $0|gr...原创 2012-11-15 15:54:32 · 220 阅读 · 0 评论 -
linux 判断指定用户对指定目录具有的权限
脚本名:power.sh脚本内容:#!/bin/shusername3=$1dir_name2=$2# get existing directoryfile_path=$dir_name2while truedo if [ -d $file_path ];then break; fi...2012-11-15 13:44:09 · 281 阅读 · 0 评论 -
【转】Shell中脚本变量和函数变量的作用域
在shell中定义函数可以使代码模块化,便于复用代码。不过脚本本身的变量和函数的变量的作用域问题可能令你费解,在这里梳理一下这个问题。(1)Shell脚本中定义的变量是global的,其作用域从被定义的地方开始,到shell结束或被显示删除的地方为止。例1:脚本变量的作用域#!/bin/bash#define the function ltx_funcltx_func(){ echo $v1...原创 2013-03-21 18:19:44 · 118 阅读 · 0 评论 -
使用awk 分析日志
直接上shell命令:awk 'BEGIN{index2=1;sum=0;}{if($0~"1003"){index2=NR;sum++;print "第"NR"行: " ,$0;} else if (NR<index2+3 ) {print $0} else if (NR==index2+3){print "\n\n\n"}}END{print "共搜索到"sum"条"2018-04-22 15:44:43 · 286 阅读 · 0 评论