Linux:echo、read、cat命令
1、echo
不换行 -n
- 举例:echo –n “My name is:”
执行命令:
举例:
kevin@kevin:~/mybash$ echo "My home dir is:$HOME my current dir is:`pwd`"
My home dir is:/home/kevin my current dir is:/home/kevin/mybash
kevin@kevin:~/mybash$
2、read
用于给变更赋值
kevin@kevin:~/mybash$ read myname
kevin
kevin@kevin:~/mybash$ echo $myname
kevin
kevin@kevin:~/mybash$ read yourname age address
kevin 30 beijing.china
kevin@kevin:~/mybash$ echo $yourname
kevin
kevin@kevin:~/mybash$ echo $age
30
kevin@kevin:~/mybash$ echo $address
beijing.china
kevin@kevin:~/mybash$
3、cat
1、创件文件
kevin@kevin:~/mybash$ cat > tmplog
create file by cat
kevin@kevin:~/mybash$ ll
总用量 16
drwxr-xr-x 2 kevin kevin 4096 2012-09-15 16:08 ./
drwxr-xr-x 44 kevin kevin 4096 2012-09-15 15:43 ../
-rwxr-xr-x 1 kevin kevin 47 2012-09-15 15:43 test.sh*
-rw-r--r-- 1 kevin kevin 19 2012-09-15 16:08 tmplog
2、查看文件,合并多个文件
kevin@kevin:~/mybash$ ll
总用量 16
drwxr-xr-x 2 kevin kevin 4096 2012-09-15 16:08 ./
drwxr-xr-x 44 kevin kevin 4096 2012-09-15 15:43 ../
-rwxr-xr-x 1 kevin kevin 47 2012-09-15 15:43 test.sh*
-rw-r--r-- 1 kevin kevin 19 2012-09-15 16:08 tmplog
kevin@kevin:~/mybash$ cat tmplog
create file by cat
kevin@kevin:~/mybash$ cat tmplog test.sh > all.log
kevin@kevin:~/mybash$ ll
总用量 20
drwxr-xr-x 2 kevin kevin 4096 2012-09-15 16:11 ./
drwxr-xr-x 44 kevin kevin 4096 2012-09-15 15:43 ../
-rw-r--r-- 1 kevin kevin 66 2012-09-15 16:11 all.log
-rwxr-xr-x 1 kevin kevin 47 2012-09-15 15:43 test.sh*
-rw-r--r-- 1 kevin kevin 19 2012-09-15 16:08 tmplog
kevin@kevin:~/mybash$ cat all.log
create file by cat
#/usr/bin/bash
echo "My name is:\c"
read name
kevin@kevin:~/mybash$
不积跬步,无以至千里;不积小流,无以成江海。