Take out the line of the specified field in the server log file

Take out the line of the specified field in the server log file

1. Take out the row of the specified field

grep password fileName #Retrieve the line containing the password field in the file name filename
grep -w password fileName #Exactly match the line code that extracts the password field in the file name filename
as follows (example):

grep -w password kk.log > kk.txt

2. Processing the retrieved data

1. If you delete and adjust the top number of each piece of data (maybe some codes, you need to delete them)

sed's/.{5}//' kk.txt #Delete the first five characters of each line of data in the file name kk.txt

The code is as follows (example):

sed 's/.\{5\}//' kk.txt > kk1.txt

Guess you like

Origin blog.csdn.net/qq_46970849/article/details/112286762