The fourth week of text processing tools

1, the statistics of / etc / passwd file in the default number of non-user shell / sbin / nologin, and users are displayed
grep -v "/ sbin / nologin $ " / etc / passwd | cut -d: - . 1 F
2, the user name of the user to detect the maximum UID, UID and shell type
sort -t: -k 3 -nr / etc / passwd | head -1 | cut -d: -f 1,3,7 | tr " : "", "
3, counts the number of connections currently connecting each remote host IP of the machine and press descending order
ss -nt | grep" ESTAB "| tr -s" ": | cut -d" "- 6 f | -nr the Sort
4, scripting createuser.sh, achieve the following functions: using a user name as a parameter, if the user specifies parameters exists to show its presence, or add it; show the user's id number, etc. added information
1) short-circuited, or manner
id $1 &>/dev/null&& echo "of the $ 1 already EXISTS" || the useradd $ 1
2) IF manner
IF ID $ 1 &> / dev / null; the then
echo "of the $ 1 already EXISTS"
the else
useradd $ 1
Exit 1
fi
5, write a script generated script basic format, including the author, contact information, version, time, and description
modification vimrc file
Global: / etc / vimrc
Personal: ~ / .vimrc

set cursorline
set hlsearch
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == 'sh'
call setline (1,"#!/bin/bash")
call setline (2,"#")
call setline (3,"#*****")
call setline (4,"#Author: 2hs")
call setline (5,"#QQ: 962248453")
call setline (6,"#Date: ".strftime("%Y-%m-%d"))
call setline (7,"#FileName: ".expand("%"))
call setline (8,"#Description: The test script")
call setline (9,"#Copyright (C): ".strftime("%Y")." All rights reserved")
call setline (10,"#****")
call setline (11,"")
endif
endfunc
autocmd BufNewFile * normal G

Guess you like

Origin blog.51cto.com/h880515/2467067