Linux 终端 Pearls

Stella981
• 阅读 467

.ssh li@10.175.68.121       #远程登陆
.ssh -l li 10.175.68.121
exit
.scp -r /home/li/TEST/unpv13e pi@192.168.31.128:/home/pi/  在主机终端中运行,复制到pi, -r表递归

.ls | grep "$*"                   #注意“号,不加的话,$*内容里可能有空格。[grep 模式 文件名...]
.ls | grep -i -n -v .*[.]c        #-i 忽略大小写,-n 打印行号,-v 对模式求反,后面匹配所有的C文件,grep的正则式与shell不同。  
.ls | grep "\<datasource\>"       #\< 单词首,\>单词尾
.ls | grep -e "data" -e "var" -e "^$"    #-e 多模式匹配,   ^匹配行首,$匹配行尾,^$匹配空行。
.ls | grep 'test\.[^h]'           #注意.的转义,加‘或”,^在[]中的意义:匹配不是.h的模式文件。
.grep -R[-r] dir                  #R[r] recursive

.find / -type f -name '*.log' -print    
.find / -name *.c -size +5000c -print   #打印字符大于5000的.c文件。
.find . -user li -print            #打印用户li的文件
.find . -perm 777 -print
.find . -atime +20 -print              #查找早于20天前访问的文件
.find . -atime +20 -exec ls -l {} \;   

.find . -name "*[ch]" | xargs wc -l   #find 命令用于管道,困惑许久,偶然遇到xargs才豁然

.cut -c1-10 data                #析取data中1~10的字符
.cut -c1,10 data                #析取data中第1和第10的字符
.cut -c10-  data                #-代表到行尾
.cut -d: -f1,6 /etc/passwd      #-d:指定:为分隔符,-f1 指定第一个字段(field)
.tr e x < infos                 #把所有的e转化为x
.tr '[a-z]' '[A-Z]' < infos     #小写转化大写
.tr -s ':' ' '  < infos         #把一个或多个:号替换为空格
.tr -d ' '      < infos         #删除空格

.uniq name                      #显示惟一行
.uniq -d name                   #找出重复的行
.uniq -c name                   #与uniq 相似,在行首显示行出现的次数

Sed   #[address1,address2][function][arguments],sed '一系列ed命令‘ 文件名 ….
.sed -n '/love/p'               #p 打印,-n 取消默认的全部打印
.sed '1,3d' filename
.sed '/Tom/d' filename
.sed '/Tom/!d' filename #!对匹配条件取反。
.sed ’s/[0-9][0-9]$/&.5/' datafile  #'&'符号代表查找串中匹配的内容。
.sed 's/old/new/gp' datafile   #g 行内全局替换
.sed 's/\(mar\)got/\1iadd/p' datafile  #包含在()里的模式保存在特定寄存器中,作为标签1,通过\1引用。
.sed -n '/west/,/east/p' datafile
.sed -n '/3,/^northeast/p' datafile
.sed -e '1,3d' -e 's/old/new/' datafile
.sed '/^north/a\\
    somethings' datafile   #在匹配的行后追加。
.sed '/^north/i\\
    somethings' datafile   #在匹配的行前添加。
.sed '/^north/c\\
    somethings' datafile   #修改当前行。
.sed '/eastern/{n; s/AM/Archine/;}' datafile #n 读取下一行。

.awk -F: '{print $2}' /etc/passwd

.tar -cf all.tar *.jpg      #-c是表示产生新的包,-f指定包的文件名。
.tar -rf all.tar *.gif      #将所有.gif的文件增加到all.tar的包里面去。-r增加.
.tar -uf all.tar logo.gif   #更新原来tar包all.tar中logo.gif文件,-u是表示更新文件的意思。
.tar -tf all.tar            #列出all.tar包中所有文件
.tar -xf all.tar            #解出all.tar包中所有文件

.tar -czf all.tar.gz *.jpg
.tar -xzf all.tar.gz

vi
.:e!            #returns you to the last saved version of the file, so you can start over.
.:0 (digit zero)       #Move to beginning of line.
.:$                    #Move to end of line.
.:2dd                  #Delete the first two lines with the cursor positioned.
.:D(d$)        #The D command deletes from the cursor position to the end of the line.

:(                      #Move to beginning of current sentence.
:)                      #Move to beginning of next sentence.
:{                      #Move to beginning of current paragraph.
:}                      #Move to beginning of next paragraph.
:[[                     #Move to beginning of current section.
:]]                     #Move to beginning of next section.

:H                      #Move to home—the top line on screen.
:M                      #Move to home—the top line on screen.
:L                      #Move to last line on screen.
:nH                     #Move to n lines below top line.
:nL                     #Move to n lines above last line.
:/pattern               #Type in the pattern that you want to find.
:?pattern               #Search backward.
:/                      #Repeat search forward.
:?                      #Repeat search backward.
:G                      #Go to end of file.
:nG                     #Go to given line n.

.vi +n file             #Opens file at line number n.
.vi + file              #Opens file at last line.
.vi +/pattern file      #Opens file at the first occurrence of pattern.

:s/old/new/g
:50,100s/old/new/g
:1,$s/old/new/g
:%s/old/new/g           #% == 1,$
:g/pattern/s/old/new/g
:g/^$/d
:!command               #Executing Unix Commands.  

.diff,cmp,comm          #diff old new(c,a,d)       
.printf "%x" 100        #SHELL下简单数值转化
.man   ascii
.man   man
.od -cb file            #(char,八进制)
.set                    #显示shell变量

.gcc -E  test.c -o test.i  #-E预处理
.gcc -M  test.c -o tmp     #-M选项指示预处理程序输出完整的依赖行,-M (Makefile)
.gcc -S test.c           #生成汇编文件
.gcc -c test.c           #生成test.o文件
.gcc -g test.c           #加入gdb调试符号, gdb a.out打开(run,break,list,next,step,print,q)
.gcc -pg test.c          #生成调用图表.
.gcc test.c -lm -o test
.ar -crl libtest.a test1.o test2.o       #创建test.a库(-cr creat and replace),-l the next argument is the name of the libary file.
.ranlib libtest.a                        #After create or modify an archive ,may need run ranlib
.ar -t  libtest.a                       #list 库中的 .o文件
.gcc -g -o test -L. -ltest use.c  #-L tells the linker what directory to look in.-l(lowercase)tells the linker what files to look for.
.cat /etc/shells                        #系统支持的shells.
.as -o test.o test.s
.ld -o test test.o
.objdump -d test.o
.ulimit -a
.ulimit -c size
.gdb a.out core                         #检查core 文件
.nm a.out                               #查看符号表
.time ./a.out    

.ifconfig

.ip addr

.ifconfig.me #查询本机外网地址网址

.Emacs
.Alt + ! 输入Shell 命令
.find . -name *.[CcHh] | etags - 在当前目录中建立工程标签(TAGS)文件

.可以查看.bash_history,.profile寻找和更改SHELL的特性.
.sudo apt-get install Ubutun下安装软件
.arp-scan --insterface en0 --localnet 扫描同一局域网内的IP,MAC(先安装arp-scan),从MAC地址特点来查找对应IP
.ssh pi@192.168.31.128               登陆pi,
sudo nc -lp 23 &(打开23端口,即telnet)
.netstat -an | grep 23 (查看是否打开23端口)
.svn co https://svn.code.sf.net/p/edk2share/code/trunk/DriverDeveloper/UefiDriverWizard .

.nautilus . #在终端下打开当前目录,类似Mac os 下open .

点赞
收藏
评论区
推荐文章
blmius blmius
2年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Jacquelyn38 Jacquelyn38
2年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
Wesley13 Wesley13
2年前
Java获得今日零时零分零秒的时间(Date型)
publicDatezeroTime()throwsParseException{    DatetimenewDate();    SimpleDateFormatsimpnewSimpleDateFormat("yyyyMMdd00:00:00");    SimpleDateFormatsimp2newS
Wesley13 Wesley13
2年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
2年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
2年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Wesley13 Wesley13
2年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
为什么mysql不推荐使用雪花ID作为主键
作者:毛辰飞背景在mysql中设计表的时候,mysql官方推荐不要使用uuid或者不连续不重复的雪花id(long形且唯一),而是推荐连续自增的主键id,官方的推荐是auto_increment,那么为什么不建议采用uuid,使用uuid究
Python进阶者 Python进阶者
3个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这