易截截图软件、单文件、免安装、纯绿色、仅160KB

linux shell script 例子1

1. 如何获得脚本参数:
#!/bin/she
#
while [ -n "$1" ]
do
case "$1" in
-a) echo "found the -a option";;
-b) param="$2"
echo "found the -b option";;
-c) echo "found the -c option";;
--) shift
break;;
*) echo "$1 is not an option";;
esac
shift
done
count=1
for para in "#@"
do
echo "parameter #$count : $para"
count=$[ $count + 1 ]
done
2.判断输入是否符合条件:
 #!/bin/sh
#
read input
if [[ $input == r* && ${#input} -eq 10 ]]; then #check the input character bits
echo "yes, your input right."
else
echo "no ,your input error."
fi
3.如何让用户输入,如果你想得到用户输入一定要记得read command.
 #!/bin/sh
#
#
read -n1 -t 10 -p "Do you want to continue [Y/N]?" answer
case $answer in
Y | y) echo
echo "fine, continue on ... ";;
N | n) echo
echo "ok, goodbye
exit;;
esac
echo "this is the end of the script"
 4.从文件中读出数据
#!/bin/sh
#
#
#
count=1
cat testfile | while read line
do
echo "Line $count : $line"
count=$[ $count + 1 ]
done
echo "finished processing the file"
#you can also use the read command to read data stored in a file on the linux system. each call to the read command reads a single line of text from the file. when there are no more lines left in the file,the read command will exit with a non-zero exit status.
5.创建自己的重定向文件描述符
#!/bin/bash
# storing STDOUT, then coming back to it
exec 3>&1
exec 1>test14out
echo "This should store in the output file"
echo "along with this line."
exec 1>&3
echo "Now things should be back to normal"
#This example is a little crazy, so let’s walk through it piece by piece. First, the script redirects file descriptor 3 to the current location of file descriptor 1, which is STDOUT. This means that any output sent to file descriptor 3 will go to the monitor.The second exec command redirects STDOUT to a file. The shell will now redirect any output se


相关文档:

实战Linux Bluetooth编程 (七) SDP协议

Service Discovery Protocol(SDP)提供一种能力,让应用程序有方法发现哪种服务可用以及这种服务的特性。
服务发现协议(SDP或Bluetooth SDP)在蓝牙协议栈中对蓝牙环境中的应用程序有特殊的含意,发现哪个服务是可用的和确定这些可用服务的特征。SDP定义了bluetooth client发现可用bluetooth server服务和它们的特征的方法。 ......

Linux 共享库:LD_LIBRARY_PATH 与ld.so.conf

今天在运行sphinx的时候,提示说
./searchd: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory
我编译安装的时候明明有指定mysql的lib库啊,上网查到是因为mysql的lib不在系统的lib路径中,解决办法如下:
在/etc/ld.so.conf下面加一行/usr/loc ......

Linux虚拟内存基础知识

1.从80386开始,Intel处理器的线性32被分为3个域,最高十位为此线性地址在页目录的索引;中间十位为此线性地址在页表中的索引;最低12为物理地址的低12位(也可以说是页内偏移量)。每个进程一定有各自独立的页表(注意:这里说的是进程,而不是线程。在linux里线程其实就是轻量级的进程,他们是连页目录都相同的进程,只是 ......

linux lib 动态库(2)

Linux系统下的Gcc(GNU C Compiler)是GNU推出的功能强大、性能优越的多平台编译器,是GNU的代表作品之一。gcc是可以在多种硬体平台上编译出可执行程序的超级编译器,其执行效率与一般的编译器相比平均效率要高20%~30%。 Gcc编译器能将C、C++语言源程序、汇程式化序和目标程序编译、连接成可执行文件,如果没有给出可执行文 ......

linux vim 配置文件

1
"
2
" @(#) This is vimrc for vim/gvim.
3
" This vimrc file will automatically configure itself based on
4
" the system it runs on (Windows/Unix).
5
" This vimrc file has been tested on SPARC/Solaris, Intel/Linux
6
" ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号