码迷,mamicode.com
首页 > 系统相关 > 详细

Linux Shell 学习笔记 00

时间:2016-10-06 22:41:52      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:

1、Bash = Bourne Again SHell

2、终端提示符:

#普通用户
username@hostname$
#管理员用户
root@hostname#

3、shell脚本通常是一个以shebang起始的文本文件:

#!/bin/bash

shebang是一个文本行,其中#!位于解释器路径之前。/bin/bash是bash的解释器的命令路径。

在Unix行话中,字符“#”通常读作“sharp”或“hash”或“mesh”来称呼,惊叹号“!”称为bang,“shebang”是指这两个字符合起来“#!”。

4、将字符串写入文本:

echo "This is a sample text!" > temp.txt 

将字符串插入文本后面:

echo "This is another sample text!" >> temp.txt

查看文本文件内容:

cat temp.txt

将错误信息stderr重新定向到文本中:

$ ls + 2> out.txt

ls + 是一条错误语句,“2>”是stderr重新定向符。

/dev/null 是一个特殊的设备文件,它接收到的任何数据都会被丢弃,被称为设备黑洞。数据一去不复返。

5、在脚本中生成延时:

#!/bin/bash

echo -n Count:
tput sc

count=0;
while true;
do
    if [ $count -lt 40 ];
    then
        let count++;
        sleep 1;
        tput rc
        tput ed
        echo -n $count;
    else exit 0;
    fi
done

 

Linux Shell 学习笔记 00

标签:

原文地址:http://www.cnblogs.com/Joseph-AMI/p/5934957.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!