Shell基础知识(六)

shell中有很多内建命令,如何区分内建命令与外部文件,使用type command即可看到命令类型。
>> type cd # input
<< cd is a Shell builtin # output
>> type ifconfig # input
<< ifconfig is /sbin/ifconfig # output
通常,内建命令运行速度更快,相当于调用当前shell进程的一个函数。而外部命令不但会触发磁盘I/O,而且还需要fork出一个单独的进程来执行,执行完成之后再退出。
 
alias是shell中的内建命令
可以利用alias对命令自定义别名,如下:
可以通过unalias进行别名删除
 
echo是shell中的内建命令
关于echo的一些性质可以直接看脚本:
#!/bin/bash

echo "hello,"
echo "world!"

echo -n "hello," # -n 可以强制不进行换行
echo "world!"

echo "this is symbol"
echo -e "this is symbol" # -e 可以对转义字符进行解析
输出:
原文地址:https://www.cnblogs.com/yinzm/p/10325079.html