通过对linux的 /root/.bashrc或~/.bashrc位置文件进行alias别名自定义函数命令,简单命令实现常用繁杂命令操作,操作配置步骤如下
1、打开.bashrc自定义函数文件[root@centos6 ~]# cat ~/.bashrc@b@# .bashrc@b@@b@# User specific aliases and functions@b@@b@alias rm='rm -i'@b@alias cp='cp -i'@b@alias mv='mv -i'@b@@b@# Source global definitions@b@if [ -f /etc/bashrc ]; then@b@ . /etc/bashrc@b@fi
或[root@centos6 ~]# cat /root/.bashrc
2、编辑.bashrc文件[root@centos6 ~]# vi ~/.bashrc@b@@b@# .bashrc@b@@b@# User specific aliases and functions@b@@b@alias rm='rm -i'@b@alias cp='cp -i'@b@alias mv='mv -i'@b@@b@# Source global definitions@b@if [ -f /etc/bashrc ]; then@b@ . /etc/bashrc@b@fi@b@@b@#打印最后多少位置日志@b@#打印最后多少位置日志@b@alias tl='tail -f /home/app/tomcat7/logs/catalina.out'@b@alias tl2='tail -f 200 /home/app/tomcat7/logs/catalina.out'@b@alias tl4='tail -f 400 /home/app/tomcat7/logs/catalina.out'@b@alias tl8='tail -f 800 /home/app/tomcat7/logs/catalina.out'@b@@b@alias cl='cat -n /home/app/tomcat7/logs/catalina.out'@b@alias vl='view /home/app/tomcat7/logs/catalina.out'@b@@b@#搜索关键词日志@b@alias gl='cat -n /home/app/tomcat7/logs/catalina.out|grep $0 --color=auto'
3、生效配置 source ~/.bashrc 并测试[root@centos6 logs]# source ~/.bashrc@b@[root@centos6 logs]# gl '192.168.1.1'@b@691: 6 1658393620 [DefaultQuartzScheduler_Worker-1] ERROR com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter @b@– runtimeError: message=[An invalid or illegal selector was specified (selector: '*,:x' error: Invalid selector: *:x).] @b@sourceName=[http://192.168.1.1/common/js/libs.js?t=2016102212059] line=[2] lineSource=[null] lineOffset=[0]@b@@b@1587: 10 1658393652 [DefaultQuartzScheduler_Worker-1] ERROR com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter @b@– runtimeError: message=[An invalid or illegal selector was specified (selector: 'input:password[data-role=visiblepassword]' @b@error: Invalid selector: input:password[data-role="visiblepassword"]).] sourceName=[http://192.168.1.1/common/js/libs.js?t=2016102212059] @b@line=[2] lineSource=[null] lineOffset=[0]@b@@b@2014: 11 1658393654 [DefaultQuartzScheduler_Worker-1] INFO com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController @b@– Re-synchronized call to http://192.168.1.1/goform/getLoginType?0.28324078999950264&_=1617556800071