Linux
文章平均质量分 70
LoveDisc
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Shell脚本的中的输入变量
$0 -> 完整的脚本路径和名称 $1 ->第一个位置变量的字符串 $2 ->第二个位置变量的字符串 $* ->所有输入参数的字符串 $@ -> 同上 $# -> 输入参数的个数 ngnlinux1 [** NONE **]/home/qius $ cat sh_test #!/bin/bash echo $0, $1,$2, $*, $@, $# shif原创 2012-07-28 16:27:48 · 2137 阅读 · 0 评论 -
如何获取shell脚本的可选参数
直接上例子: cat option_sh #!/bin/bash echo $* # get the optional arguments while getopts f:t: value do case $value in f ) RHOST_INFO=$OPTARG # 从$OPTARG中获得参数值 ;;原创 2012-07-28 16:58:10 · 2631 阅读 · 0 评论 -
read 用法
(1) 用于从terminal读入数据 ngnlinux1 [** NONE **]/home/qius $ read -p "input:" input input:shang hai is a good city ngnlinux1 [** NONE **]/home/qius $ echo $input #如果只有一个参数,这个参数将保存所有的输入 shang hai原创 2012-07-29 10:26:26 · 488 阅读 · 0 评论 -
cat命令用于输入文档到文件
(1) cat /dev/null > /etc/test.txt 把test.txt文件扔进垃圾箱 (2) #! /bin/bash scriptname="cat_test" cat >> $scriptname send "${!i}\r" expect { timeout {exit 1} -re "$lastprompt" } set timeout原创 2012-07-28 16:00:16 · 1839 阅读 · 0 评论 -
shell 变量
一,SHELL本地变量: 本地变量就如同局部变量一样,只在本SHELL中起作用。它不会影响到其他SHELL中的变量。 格式:NAME=value 1,变量的调用:在变量前加$ $ echo $HOME /home/hbwork $ WEEK=Satur $ echo Today is $WEEKday Today is $echo Today转载 2012-09-21 21:20:16 · 1244 阅读 · 0 评论 -
显示目录结构的shell脚本
# !/bin/bash current_path=`pwd` output_dir() { dir=$1 #dir is a globle varible elements=`ls $dir` echo "$2""+"${dir##/*/} #get the dir name, remove the path for each in $elem原创 2012-10-27 18:46:54 · 1118 阅读 · 0 评论 -
变量替换与扩展
原文:http://blog.youkuaiyun.com/hongkun001/article/details/6432547 一、变量替换 ${varname:-word} 如果变量varname存在且非null,则返回其值,否则,返回word ${varname-word} 如果变量varname存在,则返回其值,否则,返回word $ var= $转载 2012-10-27 16:50:32 · 432 阅读 · 0 评论 -
linux 除了某个文件或某个文件夹以外全部删除
2011-09-01 10:36 linux 除了某个文件或某个文件夹以外全部删除 比如一个目录下有1,2,3,4,5这五个文件,现在我需要删除除了2以外的所有文件,那么我可以使用 find . ! -name 2 -exec rm -f {} \; 当然你还可以配合着 -maxdepth 来更精准的删除了. 下面演示删除的范围仅限于当前目录. find . -maxdepth转载 2013-09-24 11:17:02 · 8310 阅读 · 0 评论
分享