这篇文章主要讲解了“linux的echo命令的基础用法”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“linux的echo命令的基础用法”吧!
echo最基本的就是作为输出,基本使用语法如下:
echo 要输出的内容
root@kali:~/eth20/eth20# echo hello eth20 hello eth20 root@kali:~/eth20/eth20# echo "hello eth20" hello eth20
但是如果要输出的内容中还有一些特殊字符,那么就极有可能被吃掉!
root@kali:~/eth20/eth20# echo "hello eth20 "welcome" " hello eth20 welcome
此时,我们可以使用-e这参数来开启转义!
root@kali:~/eth20/eth20# echo -e "hello eth20 \"welcome\" " hello eth20 "welcome" root@kali:~/eth20/eth20#
这样我们就可以输出特殊字符了!并且可以使用转义字符\n来实现换行!但是\n前最好留一个空格!
root@kali:~/eth20/eth20# echo -e "hello eth20 \n\"welcome\" " hello eth20 "welcome"
另外对于单引号,我们是不需要加转义字符的!
root@kali:~/eth20/eth20# echo -e "hello eth20\n\"welcome\" 'eth20'" hello eth20 "welcome" 'eth20' root@kali:~/eth20/eth20# echo -e "hello eth20\n\"welcome\" \'eth20\'" hello eth20 "welcome" \'eth20\' root@kali:~/eth20/eth20#
通过对echo的简单使用,只有能输出内容,那么就可以使用重定向符> 或者追加符>>来将我们输出的内容写入到文件中了!
另外,我们还可以通过``这个符号来通过echo执行系统命令,即使没有自动换行!
root@kali:~/eth20/eth20# echo `whoami` root root@kali:~/eth20/eth20# root@kali:~/eth20/eth20# echo `cat /etc/passwd` root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin
是不是我们就可以使用wget下载任意文件到上面了呢?或者直接使用nc来获取一个反向连接呢?
最后说一下,在windows系统中,使用echo.|命令,来执行系统命令!
F:\eth20-CTF-Toolkits\CTF工具包\注入检测\Python27\sqlmap1.1.8>echo. | whoami etxx\etxx F:\eth20-CTF-Toolkits\CTF工具包\注入检测\Python27\sqlmap1.1.8>echo.|whoami etxx\etxx F:\eth20-CTF-Toolkits\CTF工具包\注入检测\Python27\sqlmap1.1.8>
免责声明:本站发布的内容(图片、视频和文字)以原创、来自互联网转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系QQ:712375056 进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
Copyright © 2009-2021 56dr.com. All Rights Reserved. 特网科技 特网云 版权所有 珠海市特网科技有限公司 粤ICP备16109289号
域名注册服务机构:阿里云计算有限公司(万网) 域名服务机构:烟台帝思普网络科技有限公司(DNSPod) CDN服务:阿里云计算有限公司 中国互联网举报中心 增值电信业务经营许可证B2
建议您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流浏览器浏览本网站