=Start=
缘由:
在微信群里看到的一个讨论,觉得挺有启发意义的,所以在此整理一下,方便以后学习、参考。
正文:
参考解答:
head tail more less tac /etc/issue | tac rev /etc/issue | rev paste /etc/issue nano pico vi vim emacs strings hexdump -C /etc/issue awk sed [e/f/z]grep . /etc/issue
&
sort uniq nl od -c /etc/issue xxd comm /etc/issue /etc/issue dd count=1000 bs=1 if=/etc/issue 2>/dev/null php -r "echo file_get_contents('/etc/issue');" python -c "print(open('/etc/issue').read())" perl -e 'open(DATA, "</etc/issue"); while(<DATA>) {print "$_";} close(DATA);' ruby -e 'IO.foreach("/etc/issue"){|a| print a}' echo $(</etc/issue) echo `</etc/issue`
&
curl file:///etc/issue base64 -i /etc/issue | base64 -d xsubpp /etc/issue /bin/c?? /etc/issue #这个只是利用了通配符来间接调用 /bin/cat 命令 bash -v /etc/issue #靠报错来实现,但显示不全 man /etc/issue #显示不全 ssh -F /etc/issue #未成功
参考链接:
- https://superuser.com/questions/112316/what-is-the-shell-command-to-display-contents-of-a-file
- https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Step_by_Step_Guide/s1-viewingtext-terminal.html
- https://2buntu.com/articles/1491/viewing-text-files-on-linux-cat-head-tail-more-and-less/
- http://linuxtools-rst.readthedocs.io/zh_CN/latest/base/03_text_processing.html
=END=
《 “Linux下如何不用cat命令读取文件内容” 》 有 5 条评论
Linux花式读取文件内容的几个命令
https://xz.aliyun.com/t/2281
`
static-sh读取文件:static-sh ./flag.txt等同于/???/??????-?? ./flag.txt
paste读取文件paste ./flag.txt /etc/passwd
diff读取文件 diff ./flag.txt /etc/passwd
od读取文件od -a ./flag.txt
bzmore读取文件bzmore ./flag.txt
bzless读取文bzless ./flag.txt
`
Bash 读取 /etc/passwd 的特殊技巧
https://twitter.com/i/web/status/999229294286077954
GTFOBins – 用来绕过本地安全限制的UNIX二进制文件的精简列表
https://gtfobins.github.io/
`
ash
awk
bash
csh
curl
dash
ed
emacs
env
expect
find
ftp
gdb
ionice
ld.so
less
man
more
nc
node
perl
php
python2
python3
rpm
rpmquery
ruby
scp
setarch
sftp
socat
ssh
strace
tar
taskset
tclsh
telnet
tftp
vi
watch
wget
wish
zsh
`
【整理】Linux输出内容追加时间戳
http://www.jyguagua.com/?p=3967
https://stackoverflow.com/questions/11731177/how-to-append-a-timestamp-to-each-line-as-it-comes-out-of-grep
`
# 相同的静态时间戳
… | sed “s/^/$(date) /” >> output.txt
# 相对时间戳
… | gawk ‘{ print strftime(), $0 }’
… | gawk ‘{ print strftime(“%Y-%m-%d %H:%M:%S”), $0 }’
… | awk ‘{ print strftime(“%Y-%m-%d %H:%M:%S”), $0; fflush() }’
# 使用 Perl
… | perl -pe ‘s/^/localtime . ” “/e’
… | perl -MPOSIX -pe ‘s/^/strftime(“%Y-%m-%d %H:%M:%S”, localtime) . ” “/e’
`
如何在命令行中将文件内容中的行倒序输出?
How can I reverse the order of lines in a file?
https://stackoverflow.com/questions/742466/how-can-i-reverse-the-order-of-lines-in-a-file
`
# Using sed to emulate tac:
sed ‘1!G;h;$!d’ ${infile}
sed -n ‘1!G;h;$p’ ${infile}
tail -r infile
awk ‘{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j–] }’ infile
perl -e ‘print reverse ‘ infile
`
https://unix.stackexchange.com/questions/9356/how-can-i-print-lines-from-file-backwards-without-using-tac