1. Use a command to find the files that have been modified in the last 24 hours in the/etc/directory, and the suffix name is
the. log file and delete it.
Find/etc-type f-mtime-1-name "log* "-exec rm-rf {} \;
2. From the Test.log file, find the row containing "not", "Fail" or "Error", without the "Info" field, and then find the last column field separated by the colon ":".
Cat Test.log |grep-e "not"-e "Fail"-E "Error" |grep-v "Info" |awk-f: ' {print $NF} '
3, directory/test/There are 100 ordinary files, some files have suffix. txt, some do not have a suffix, write a script, the/test/directory of all files without the suffix name of the file is renamed to end in. txt.
#!/bin/bash
cd/test/
For AA infind . - type f ! -name "*.txt"
Do
MV $aa $AA. txt
Done
4, write a scheduled task script, every Monday 01:30 the/opt/directory of all the contents of the package backup to the/data/backup/directory, and the file name is yyyymmdd-opt,yyyy for the year, MM for the month, DD for the day.
Crontab–e
1 1/home/aa.sh >/dev/null 2>&1
#!/bin/bash
#/home/aa.sh
Time=date +%Y%m%d
Tar czvf $time-opt/opt/
MV $time-opt/data/backup/
5. Use a command to count the number of visits per IP address in Apache access log access.log, and list the top 10 by traffic.
Examples of the log grid styles are as follows:
192.168.1.10--[24/jul/2017:23:55:55 +0800] "get/http/1.1" 200 19
More Access_log | awk ' {print '} ' | uniq-c | Sort-rn | Head-10
6, print out the test.conf file does not start with "#", and is not a blank line of content.
Sed-e "/^#/d" test.conf | awk ' {if (length!=0) print $} '
7, write a scheduled task, every 2 hours to perform a/opt/app/test.sh.
Crontab–e
- /2 /opt/app/test.sh >/dev/null 2>&1
Shell Daily Script