Linux小笔记
ps -ef|grep jboss ls -h -l
--查找
204.204 uat查看日志 10.0.204.204
写应用:
cd /jboss/eshop/jboss_write/server/web/log/
tail -f server.log
读应用1(8180):
cd /jboss/eshop/jboss_read1/server/web/log/
tail -f server.log
读应用2(8280):
cd /jboss/eshop/jboss_read2/server/web/log/
tail -f server.log
Linux查找文件内容的常用命令方法。
从文件内容查找匹配指定字符串的行:
$ grep "被查找的字符串" 文件名例子:在当前目录里第一级文件夹中寻找包含指定字符串的.in文件
grep "thermcontact" */*.in
从文件内容查找与正则表达式匹配的行:
$ grep –e “正则表达式” 文件名
查找时不区分大小写:
$ grep –i "被查找的字符串" 文件名
查找匹配的行数:
$ grep -c "被查找的字符串" 文件名
从文件内容查找不匹配指定字符串的行:
$ grep –v "被查找的字符串" 文件名
从根目录开始查找所有扩展名为.log的文本文件,并找出包含”ERROR”的行
find / -type f -name "*.log" | xargs grep "ERROR"
例子:从当前目录开始查找所有扩展名为.in的文本文件,并找出包含”thermcontact”的行
find . -name "*.in" | xargs grep "thermcontact"
如:sed -n '5,10p' /etc/passwd
这样你就可以只查看文件的第5行到第10行。
解释:
wc [-lmw]
查看linux文件目录的大小和文件夹包含的文件数
统计总数大小
du -sh xmldb/
du -sm * | sort -n //统计当前目录大小 并安大小 排序
du -sk * | sort -n
du -sk * | grep guojf //看一个人的大小
du -m | cut -d "/" -f 2 //看第二个/ 字符前的文字
查看此文件夹有多少文件 /*/*/* 有多少文件
du xmldb/
du xmldb/*/*/* |wc -l
40752
# ls -lh
total 30M
-rw-r--r-- 1 root root 30M May 24 10:07 cuss.war
-rw------- 1 root root 0 Mar 20 13:52 nohup.out
# ll -h
total 30M
-rw-r--r-- 1 root root 30M May 24 10:07 cuss.war
-rw------- 1 root root 0 Mar 20 13:52 nohup.out
----------------------------------------------------------------
ssh 上通过 curl方式 访问 post/get
curl -i -X POST -H "Content-Type:application/json"
目的1:通过脚本发送post请求。
答案: curl -d "leaderboard_id=7778a8143f111272&score=19&app_key=8d49f16fe034b98b&_test_user=test01" "http://172.16.102.208:8089/wiapi/score"
目的2:通过脚本发送post请求,顺便附带文本数据,比如通过"浏览"选择本地的card.txt并上传发送post请求
答案: curl -F "blob=@card.txt;type=text/plain" "http://172.16.102.208:8089/wiapi/score?leaderboard_id=7778a8143f111272&score=40&app_key=8d49f16fe034b98b&_test_user=test01"
其中-F 为带文件的形式发送post请求, blob为文本框中的name元素对应的属性值。<type="text" name="blob">
用curl命令,post提交带空格的数据
今天偶然遇到一个情况,我想用curl登入一个网页,无意间发现要post的数据里带空格。比如用户名为"abcdef",密码为"abc def",其中有一个空格,按照我以前的方式提交:
curl -D cookie -d "username=abcdef&password=abc def" http://login.xxx.com/提示登入失败。
于是查看curl手册man curl。找到:
d/--data (HTTP) Sends the speci?ed data in a POST request to the HTTP server, in a way that can emulate as if a user has ?lled in a HTML form and pressed the
submit button. Note that the data is sent exactly as speci?ed with no extra processing (with all newlines cut off). The data is expected to be "url-encoded".
This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded. Compare to -F/--form. If this option is used
more than once on the same command line, the data pieces speci?ed will be merged together with a separating &-letter. Thus, using ’-d name=daniel -d
skill=lousy’ would generate a post chunk that looks like ’name=daniel&skill=lousy’.
于是改用:
curl -D cookie -d "username=abcdef" -d "password=abc efg" http://login.xxx.com/这样就能成功登入了。
浙公网安备 33010602011771号