别名 grep vim报错解决方案

vim 产生报错故障原因

1 同时打开了一个文件
2 之前的文件未保存非正常退出
报错:

E325: ATTENTION
Found a swap file by the name "/tmp/.oldboy.txt.swp"
          owned by: root   dated: Mon Apr  8 16:18:52 2019
         file name: /tmp/oldboy.txt
          modified: YES
         user name: root   host name: oldboyznb
        process ID: 7696
While opening file "/tmp/oldboy.txt"
             dated: Mon Apr  8 11:26:26 2019

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r /tmp/oldboy.txt"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/tmp/.oldboy.txt.swp"
    to avoid this message.

Swap file "/tmp/.oldboy.txt.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

Interrupt: Press ENTER or type command to continue

解决方案:

①.删除这个临时文件 (推荐)
错误提示中有文件名字

[root@oldboyznb ~]# rm -rf /tmp/.oldboy.txt.swp

②.把临时文件的内容恢复(不推荐)

别名:给命令起小名

用途:①给危险命令起小名
       ②长命令变短,省事

修改别名:

临时修改,重启登录后失效

1 [root@oldboyznb  ~]# alias   rm='rm-i/etc/sysconfig/network-scripts/ifcfg-eth0'

2永久修改,在/etc/profile

[root@oldboyznb  ~]# tail -1 /etc/profile
alias net='cat /etc/syscofig/network-scripts/ifcfg-eth0'

检查 alias net

root@maoyihan ~]# alias net
alias net='cat /etc/syscofig/network-scripts/ifcfg-eth0'
[root@maoyihan ~]# 

临时取消别名
\rm或/usr/bin/rm或unalias rm

三剑客老三 grep 在文件中查找、过滤

alias 修改别名

临时修改
[root@oldboyznb  ~]# alias net='cat /etc/sysconfig/network-scripts/ifcfg-eth0'
永久修改
[root@oldboyznb  ~]# vim /etc/profile
alias net='cat /etc/sysconfig/network-scripts/ifcfg-eth0'\

grep 过滤 筛选出文件中需要的内容等

[root@oldboyznb ~]# grep 'IP' /etc/sysconfig/network-scripts/ifcfg-eth0
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
IPADDR=10.0.0.202
IPV6_PRIVACY=no
[root@oldboyznb ~]# 

grep –n 显示行号和内容
grep –w 按照单词进行过滤(相邻没有其他字符)
grep –I 过滤的时候忽略大小写
grep –v 排除/取反,找出不包含内容的行

tr 简单的1对1替换 必须加入<输入重定向

只能1对1字符替换,不能替换字符串

[root@oldboyznb ~]# tr 'a' 'A' <  /oldboy/oldboy.txt
oldboy
mAoyiAhn
lidAy
mAoyiAhn
lidAy
mAoyiAhn
lidAy
mAoyiAhn
lidAo
Alex

你可能感兴趣的:(别名 grep vim报错解决方案)