
shell
majinbo111
这个作者很懒,什么都没留下…
展开
-
Linux sed 命令
sed介绍Linux sed 命令是利用脚本来处理文本文件。sed 可依照脚本的指令来处理、编辑文本文件。Sed 主要用来自动编辑一个或多个文件、简化对文件的反复操作、编写转换程序等。语法sed [-hnV][-e<script>][-f<script文件>][文本文件]参数说明:-e<script>或--expression=<script> 以选项中指定的script来处理输入的文本文件。-f<script文件>或--file原创 2022-01-28 17:02:45 · 613 阅读 · 0 评论 -
awk 内部的字符串拼接及命令执行
awk 内部的字符串拼接及命令执行awk '{ print "line:",NR,$0; filename="/tmp_dir/"$1"_"$3".pdf"; print filename; cmd="curl -o "filename" "$2; print cmd; system(cmd);}' test.csv原创 2020-12-01 10:33:48 · 2915 阅读 · 0 评论 -
mac os zcat: can't stat:
Question: mac os zcat: can’t stat:$ zcat test.gzzcat: can’t stat: test.gz (test.gz.Z): No such file or directoryAnwsercase 1:zcat < test.gz | head -n 10case 2:gunzip -c test.gz | head -...原创 2020-04-09 01:44:59 · 1144 阅读 · 0 评论 -
ls sort by time
linux man ls-l (The lowercase letter ``ell''.) List in long format. (See below.) A total sum for all the file sizes is output on a line before the long listing.-r Reverse the order of ...原创 2020-03-18 21:57:52 · 895 阅读 · 0 评论 -
git clone ssh 方式无法使用
问题git clone git@test.com:test123.gitCloning into 'test123'...ssh_exchange_identification: read: Connection reset by peerfatal: Could not read from remote repository.Please make sure you have the...原创 2019-12-26 17:53:40 · 3339 阅读 · 0 评论 -
bash: /usr/bin/curl: Argument list too long
Problemexec curl alert “bash: /usr/bin/curl: Argument list too long”image=base64 test.jpgcurl -X POST -F 'image=${image}' "url"# alert messagebash: /usr/bin/curl: Argument list too longhow to f...原创 2019-12-25 16:21:25 · 3066 阅读 · 0 评论 -
shell mail and sendmail
shell mail and sendmailmailman mail ,for exampl:echo 'body' | mail -s "Subject" -t mail@domain.com -a From:mail@domain.comsendmailsend mail with body and attachment, for example(support Chin...原创 2019-12-24 15:39:47 · 434 阅读 · 0 评论 -
shell echo -e
man echoECHO(1) User Commands ECHO(1)NAME echo - display ...原创 2019-11-28 11:52:10 · 475 阅读 · 0 评论 -
Find the largest open file through lsof
Find the largest open file through lsofsudo lsof -u jinbo| sort -n -k 8 -u -r | head -n 2Referencesort help$ sort --helpUsage: sort [OPTION]... [FILE]... or: sort [OPTION]... --files0-from=F...原创 2019-05-28 15:45:18 · 483 阅读 · 0 评论 -
Crontab avoid multiple executions
ContentFirst Wayflock helpcrontab configSecond WayAttention Programing LanguageReferenceTwo ways of crontab avoiding multiple executions. The first way is to use the shell command flock to implement,...原创 2019-05-23 20:03:23 · 115 阅读 · 0 评论 -
host 获取一组机器的IP地址
原理$ host test.dev1.jinbo.comtest.dev1.jinbo.com has address 192.168.10.1批量获取一组机器的IP地址for i in {1..5}; do host test.dev${i}.jinbo.com | awk '{print $4}'; done;192.168.10.1192.168.10.2192.168.10...原创 2019-05-11 18:03:17 · 1031 阅读 · 0 评论 -
systemtap install ubuntu
机器环境uname -r4.15.0-47-genericuname -aLinux jinbo-Latitude-E5440 4.15.0-47-generic #50-Ubuntu SMP Wed Mar 13 10:44:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linuxlsb_release -aNo LSB modules are ava...原创 2019-04-25 11:16:41 · 1392 阅读 · 0 评论 -
curl 指定host ip 访问页面或接口
服务器太多了,查找错误的时候又想指定机器且快速访问,去查看错误日志,怎么办呢? 使用curl的解决方式:curl -H 'Host:www.test.com' http://10.44.54.111/test.php或curl -x 10.44.54.111:80 http://www.test.com/test.php...原创 2018-07-23 14:51:54 · 57598 阅读 · 0 评论 -
curl 如何传递多参数且urlencode编码
案例1curl -d “dep=北京&arrive=西安” test.comnginx的日志里的汉字变成了16进制(UTF16编码)展示了,如下:127.0.0.1 - - [22/Mar/2019:10:17:21 +0800] “POST / HTTP/1.1” , “dep=\xE5\x8C\x97\xE4\xBA\xAC&arrive=\xE8\xA5\xBF\xE...原创 2019-03-22 10:23:06 · 11493 阅读 · 0 评论 -
ss命令
ss命令转载 2019-01-10 23:32:40 · 1886 阅读 · 0 评论 -
shell for 学习
#!/bin/bashfor_1 () { echo "for 1 show item" for var in item1 item2 ... itemN do echo ${var}; done}for_2 () { echo "for 2 show 1~5" for loop in 1 2 3 4 5 do ...原创 2018-04-08 12:06:53 · 144 阅读 · 0 评论 -
查看文件时间戳命令 stat
$stat test.txtFile: ‘test.txt’Size: 10456 Blocks: 24 IO Block: 4096 regular fileDevice: fd06h/64774d Inode: 268948028 Links: 1Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: (原创 2017-11-21 11:24:56 · 2843 阅读 · 0 评论 -
vim 打开sudo权限文件不退出保存
It’s easy:w !sudo tee %Why do you do that?: vim insert modelw Write a file.!sudo All shell sudo command.tee The output of the vi/vim write command is redirected using tee.% Triggers the use原创 2017-11-01 21:39:44 · 1515 阅读 · 0 评论 -
shell alias
alias 使用格式: alias xxx=’shell cmd’ 命令的别名 使用alias 一般在.bashrc 文件中使用,将比较长的命令重命名成比较短的命令,这样xxx直接可以在命令行中取代后边对应的shell 命名。 注:一般将alias写入.bashrc 文件中,保存使用source .bashrc 命令重载一下这个文件就好了。原创 2015-11-04 15:07:31 · 535 阅读 · 0 评论 -
updatedb与locate
locate查找命令不能查找不我们最新创建的文件,因为系统的数据库还没有更新,若果我们手动更新数据库便可以查到。 updatedb 就是更新系统数据库的命令updatedb 最好使用root 权限去执行,否会遇到“updatedb: 无法为 `/var/lib/mlocate/mlocate.db’ 打开临时文件”,这种类似的问题。之后再使用locate 去查找自己要的东西,速度比find 快的多原创 2016-01-14 11:03:21 · 3958 阅读 · 0 评论 -
查看目录占用空间及有多少文件
查看某目录占用空间:du -sh directory查看某目录下有多少个文件:find directory -type f | wc -lfind 命令示例find 查找当前目录下有多少个c文件find ./ -type f -name "*.c" | wc -lfind 命令简单解释参数 -type 代表文件的类型,文件类型对应如下关系b 块文件 (如内存)c 字符文件 (如串口)原创 2016-04-08 10:23:22 · 1384 阅读 · 0 评论 -
查看文件的中间行
注:以下仅限命令行使用方式一:使用cat、head、tail组合查看示例文件 test:1 a2 b3 c4 d5 e6 f7 g8 h9 i10 j11 k12 l13 m14 n1、显示test文件的第5~9行cat test | tail -n 10 | head -n 52、显示test文件的第6行~10行cat te原创 2016-04-21 15:28:05 · 758 阅读 · 0 评论 -
linux shell set
set命令作用主要是显示系统中已经存在的shell变量,以及设置shell变量的新变量值。使用set更改shell特性时,符号”+”和”-“的作用分别是打开和关闭指定的模式。set命令不能够定义新的shell变量。如果要定义新的变量,可以使用declare命令以变量名=值的格式进行定义即可。原创 2016-06-28 16:53:02 · 558 阅读 · 0 评论 -
crontab 保持单进程执行
方式一 在运行该定时任务时,先获取当前进程列表里是否当前进程,有则停止,无则运行方式二 借助临时文件以flock的独占锁去实现,如果访问某文件有文件锁则停止,无则先上独占锁,之后再执行,执行完之后一定要释放文件锁,否则进入了死循环原创 2016-07-25 15:21:56 · 1756 阅读 · 0 评论 -
bash配置及应用
.inputrcbash的自动补全功能可以这样设置:.inputrc 中增加两行:set completion-ignore-case onset completion-map-case on然后tab匹配的时候忽略大小写、忽略横杠、下划线!history扩展自己的history的大小,设置方法如下: $ echo "HISTCONTROL=ignoreboth" >>~/.bashrcvim/v原创 2016-07-27 09:54:42 · 723 阅读 · 0 评论 -
ubuntu14.04 SSH免密码远程登陆
1、ssh远程登陆 http://jingyan.baidu.com/album/9c69d48fb9fd7b13c8024e6b.html?picindex=92、ssh免密码登陆 http://jingyan.baidu.com/article/60ccbceb02bd4264cab197b9.html原创 2014-12-06 20:34:56 · 1690 阅读 · 0 评论 -
bash使用正则匹配方法--shopt -s extglob
问题:一个日志目录,里头存着很多 00, 01, 02 … 31 的日期目录,如何列示出00到12号之间的所有目录?也就是说,如何在文件名上面,使用正则?shopt (shell option 这么理解易记)$ shoptautocd offcdable_vars offcdspell offcheckhash offcheckjobs原创 2016-07-20 11:58:20 · 6210 阅读 · 0 评论 -
sshfs 远程文件映射
sshfs ubuntu 安装$ sudo apt-get install sshfssshfs 用例$ sshfs username@host:source_name dest_name# source_name 远程机器的文件或目录# dest_name 本地映射的目录或文件 取消远程文件映射$ fusermount -u MountDir原创 2016-08-01 19:05:37 · 459 阅读 · 0 评论 -
linux nc
nc cmd linux原创 2016-08-29 17:00:15 · 557 阅读 · 0 评论 -
在linux中查看磁盘空间的大小
df -hl 查看磁盘剩余空间 df -h 查看每个根路径的分区大小du -sh [目录名] 返回该目录的大小 du -sm [文件夹] 返回该文件夹总M数原创 2016-09-02 19:32:56 · 1768 阅读 · 0 评论 -
查看io负载的命令
查看io vmstat 2 iostat 2查看负载 uptime隔几秒查看命令 watch文件只读 加锁 sudo chattr +i day_get_order.php查看加锁文件 lsattr查看要命的进程 ps awx -o pid,ppid,user,%cpu,vsz,wchan,command –sort=+%cpu,-command,+ppid,+pid | egr原创 2017-03-23 08:40:08 · 4936 阅读 · 0 评论 -
统计用到的shell命令
access日志里排名前十的IPawk '{print $1}' current_access.log | sort |uniq -c | sort -rn | head -n 10原创 2017-05-02 19:55:54 · 308 阅读 · 0 评论 -
查看linux中某个端口(port)是否被占用
第一种方式:lsof -i:port如:ls -i:80第二种方式:netstat -anp|grep 80原创 2017-04-17 14:36:55 · 1340 阅读 · 0 评论 -
处理交互分区
首先查看内存剩余:$free -m保证剩余内存的空间可以存放现有交换分区被占用的空间,就可以使用下边的命令去处理:$sudo swapoff -a && sudo swapon -a原创 2017-05-31 18:03:29 · 340 阅读 · 0 评论 -
查看自己账号的sudo权限
查看自己账号的sudo权限sudo -l原创 2017-09-20 18:19:14 · 8525 阅读 · 0 评论 -
linux scp 远程拷贝
1、拷贝本机/home/administrator/test整个目录至远程主机192.168.1.100的/root目录下 scp -r /home/administrator/test/ root@192.168.1.100:/root/2、拷贝单个文件至远程主机 scp /home/administrator/Desktop/old/dri原创 2014-12-07 17:36:02 · 512 阅读 · 0 评论