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

Linux Shell 笔记一

最近在学习linux,在这里给大家推荐一个网站http://linux.vbird.org/ 上面关于linux的教程写得很好,也避免了我在学习过程中的很多弯路。
程序一:HelloWord,在屏幕输出HelloWord
利用vim 创建一个sh01.sh文件
echo -e "Hello World!\a\n"
exit 0

程序二:将输入参数拼接后输出
read -p "First Name:" firstname
read -p "Last Name:" lastname
echo -e "\n your full name is:$firstname $lastname"
程序三:
根据日期创建文件
echo -e "I will use touch comand to create 3 file.\n"
read -p "please input the filename what you want:" fileuser
filename=${fileuser:-"filename"}
date1=`date --date='2 days ago' +%Y%m%d`
file1="$filename""$date1"
touch $file1".log"

程序四:普通计算
[root@localhost scripts]# cat sh4.sh
read -p "first:" first
read -p "second:" second
total=$(($first*$second))
echo -e "\n========>$total"

程序五:查找文件,判定权限
[root@localhost scripts]# cat sh5.sh
echo -e "input filename"
read -p "input the filename you want:" filename
test -z $filename && echo "\filename can't be null" && exit 0
test ! -e $filename && echo "file not exist!" && exit 0
test -f $filename && filetype="regulare file"
test -d $filename && filetype="directory"
test -r $filename && perm="readable"
test -w $filename && perm="$perm writable"
test -x $filename && perm="$perm executable"
echo "The filename:$filename is a $filetype"
echo "And the permission are :$perm"

程序六:if else
[root@localhost scripts]# cat sh6.sh
echo "hello world ,shell"
[ -n "$0" ] && echo "$0" || exit 0
[ -n "$1" ] && echo "$1" || exit 0
echo "shell over!"
exit 0
#调用时采用 sh sh6.sh par1 par2
#其中sh6.sh为第一个参数
#par1为第二个参数
#$0取第一个参数,$1取第二个参数

程序7:if else(2)
[root@localhost scripts]# cat sh7.sh
read -p "yes or no (y/n)?" ny
#注意空格!!
if [ "$ny" == "Y" ] || [ "$ny" == "y" ]; then
echo "OK,continue"
exit 0
fi
if [ "$ny" == "N" ] || [


相关文档:

linux ,路在何方?

 
学linux也有一段时间了,从一个菜鸟成长为蹒跚走路的雏鸟,一路走来,难免有些磕磕碰碰。对linux的认识也从听说很强大,到亲自体验它的开源、安
全、以及优越的性能,不过也吃尽了苦头,真的是五味俱全。
    
都说linux功能强大,自从我接触了linux就感觉到了它的强大。强大的安全性能, ......

linux远程桌面管理VNC

author:skate
time:2010-05-24
以前也用过linux的远程图形界面管理程序x-win32,地址如下:
http://blog.csdn.net/wyzxg/archive/2007/09/10/1779148.aspx  
今天介绍在介绍一个图形管理软件vnc,简单配置如下
vnc服务端os版本:centos4.7
vnc client: nvc viewer客户端
1.检查vnc服务器是否安装
[root@ ......

Linux下的多线程编程


Linux下的多线程编程
作者:姚继锋 2001-08-11 09:05:00
来自:http://www.china-pub.com
1 引言
  线程(thread)技术早
在60年代就被提出,但真正应用多线程到操作系统中去,是在80年代中期,solaris是这方面的佼佼者。传统的Unix也支持线程的概念,但是在一个
进程(process)中只允许有一个线程,这样多线程 ......

搜索文件夹内的所有文件里包含某字符串的linux命令

从文件内容查找匹配指定字符串的行:
$ grep "被查找的字符串" 文件名
从文件内容查找与正则表达式匹配的行:
$ grep –e “正则表达式” 文件名
查找时不区分大小写:
$ grep –i "被查找的字符串" 文件名
查找匹配的行数:
$ grep -c "被查找的字符串" 文件名 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号