|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
linux系统的文件布置,etc/,opt/目录的内容等;
1.输入重定向:
默许前提下,尺度输入和毛病输入都是终端,能够把尺度输入和毛病内容举行重定向:
.代码以下:
[~]#echo"hello!"
hello!
[~]#echo"hello!"
-bash:!":eventnotfound"
把尺度输入重定向到文件
.代码以下:
[~]#echo"hello">test.sh
[~]#cattest.sh
hello
>输入体例默许等价1>
[~]#echo"hello"1>test.sh
[~]#cattest.sh
hello
可是毛病内容仍是会显现在屏幕上:
.代码以下:
[~]$catedit.sql/root/test.sh>temp.sh
cat:/root/test.sh:Permissiondenied
能够把毛病内容也输入到文件中(使用文件形貌符):
.代码以下:
[~]$catedit.sql/root/test.sh1>temp.sh2>error.sh
[~]$cattemp.sh
selectdbms_rowid.rowid_object(AAAZdQAAGAAATxjAAk)data_object_id#,
dbms_rowid.rowid_relative_fno(AAAZdQAAGAAATxjAAk)rfile#,
dbms_rowid.rowid_block_number(AAAZdQAAGAAATxjAAk)block#,
dbms_rowid.rowid_row_number(AAAZdQAAGAAATxjAAk)row#fromdual
/
[~]$caterror.sh
cat:/root/test.sh:Permissiondenied
把尺度输入和毛病信息写进统一个文件:
.代码以下:
[~]$catedit.sql/root/test.sh>temp.sh2>&1
[~]$cattemp.sh
selectdbms_rowid.rowid_object(AAAZdQAAGAAATxjAAk)data_object_id#,
dbms_rowid.rowid_relative_fno(AAAZdQAAGAAATxjAAk)rfile#,
dbms_rowid.rowid_block_number(AAAZdQAAGAAATxjAAk)block#,
dbms_rowid.rowid_row_number(AAAZdQAAGAAATxjAAk)row#fromdual
/
cat:/root/test.sh:Permissiondenied
这个看起来对照贫苦,实践使用中大概用的最多的是:
.代码以下:
[~]$catedit.sql/root/test.sh&>temp.sh
[~]$cattemp.sh
selectdbms_rowid.rowid_object(AAAZdQAAGAAATxjAAk)data_object_id#,
dbms_rowid.rowid_relative_fno(AAAZdQAAGAAATxjAAk)rfile#,
dbms_rowid.rowid_block_number(AAAZdQAAGAAATxjAAk)block#,
dbms_rowid.rowid_row_number(AAAZdQAAGAAATxjAAk)row#fromdual
/
cat:/root/test.sh:Permissiondenied
&>把一切输入都写进统一个文件
假如不想输入到文件,也不想在屏幕上显现,能够使用/dev/null这一特别设备文件(bitbucket)
[~]$catedit.sql/root/test.sh&>/dev/null
假如把尺度输入写进到文件,就没法使用管道标记|把内容传给接上去的命令,能够使用tee命令办理这个成绩:
.代码以下:
[~]$catedit.sql/root/test.sh|teetemp.sh|cat-n
cat:/root/test.sh:Permissiondenied
selectdbms_rowid.rowid_object(AAAZdQAAGAAATxjAAk)data_object_id#,
dbms_rowid.rowid_relative_fno(AAAZdQAAGAAATxjAAk)rfile#,
dbms_rowid.rowid_block_number(AAAZdQAAGAAATxjAAk)block#,
dbms_rowid.rowid_row_number(AAAZdQAAGAAATxjAAk)row#fromdual
/
tee命令相称于把stdout正本写进文件,再把stdout传给下一个命令,可是毛病内容是没法用tee传送的,好像利用>>追加内容,tee可使用-a选项追加:
.代码以下:
[~]$catedit.sql/root/test.sh|tee-atemp.sh|cat-n
cat:/root/test.sh:Permissiondenied
selectdbms_rowid.rowid_object(AAAZdQAAGAAATxjAAk)data_object_id#,
dbms_rowid.rowid_relative_fno(AAAZdQAAGAAATxjAAk)rfile#,
dbms_rowid.rowid_block_number(AAAZdQAAGAAATxjAAk)block#,
dbms_rowid.rowid_row_number(AAAZdQAAGAAATxjAAk)row#fromdual
/
[~]$cattemp.sh
selectdbms_rowid.rowid_object(AAAZdQAAGAAATxjAAk)data_object_id#,
dbms_rowid.rowid_relative_fno(AAAZdQAAGAAATxjAAk)rfile#,
dbms_rowid.rowid_block_number(AAAZdQAAGAAATxjAAk)block#,
dbms_rowid.rowid_row_number(AAAZdQAAGAAATxjAAk)row#fromdual
/
selectdbms_rowid.rowid_object(AAAZdQAAGAAATxjAAk)data_object_id#,
dbms_rowid.rowid_relative_fno(AAAZdQAAGAAATxjAAk)rfile#,
dbms_rowid.rowid_block_number(AAAZdQAAGAAATxjAAk)block#,
dbms_rowid.rowid_row_number(AAAZdQAAGAAATxjAAk)row#fromdual
/
2.输出重定向:
输出重定向,在一些场所,比方数据库监控顶用的对照多,罕见的是利用内联重定向
.代码以下:
[~]$cat<edit.sql
selectdbms_rowid.rowid_object(AAAZdQAAGAAATxjAAk)data_object_id#,
dbms_rowid.rowid_relative_fno(AAAZdQAAGAAATxjAAk)rfile#,
dbms_rowid.rowid_block_number(AAAZdQAAGAAATxjAAk)block#,
dbms_rowid.rowid_row_number(AAAZdQAAGAAATxjAAk)row#fromdual
/
比方,以下操纵,把<<EOF>temp.sh到最初EOF之间的内容看成stdin,然后把stdout写进文件temp.sh
.代码以下:
[~]$cat<<EOF>temp.s
thisismylog
EOF
[~]$cattemp.sh
thisismylog
3.自界说文件形貌符:
自界说文件形貌符的道理是利用基础的三种文件翻开形式
只读(<)
截断(>)
追加(>>)
创立一个文件形貌符3,用于翻开文件
[~]#exec3<test.sh
上面就能够间接利用文件形貌符翻开文件了,可是只能利用一次:
.代码以下:
[~]#cat<&3
hello
hello
创立文件形貌符4,用于写进文件(能够复用):
.代码以下:
[~]#exec4>test.sh
[~]#echookok>&4
[~]#cattest.sh
okok
这个实践相似后面的:
.代码以下:
[~]$catedit.sql/root/test.sh>temp.sh2>&1
创立文件形貌符5,用于向文件追加内容(也能够复用,不像输出文件形貌符那样只能利用1次):
.代码以下:
[~]#exec5>>test.sh
[~]#echookokok>&5
[~]#cattest.sh
okokok
[~]#echookokok>&5
[~]#cattest.sh
okokok
okokok
使用gcc或g++进行编译,使用gdb进行调试; |
|