Time when the file is read
#! /Bin/bash
For file in 'ls/root'
Do
Stat $ file> 1.txt
Sed-n "7 p" 1.txt> 2.txt
Usetime = awk-F ":" '{print $2}' 2.txt
Echo "time =" $ file $ usetime
Done
The while statement that reads each row of a file.
Cat afile | while read oneline
Do
Echo $ oneline
Done
The for statement is used to read each row of a file.
For I in 'cat afile'
Do
Echo $ I
Done
Ø automatically add users
Useradd test
Passwd test <eof
111111
111111
Eof
Automatic Process killing
Ps-a | grep ''| awk '{print $1}' | xargs-I kill 9 {}
Retain files for seven days
#! /Bin/bash
For file in 'ls/orabak'
Do
If [[$ {file: 0: 2 }== "db"]; then
Fdate =$ {file: 10: 8}
Mydate = 'date + % Y % m % d-d "-7 day "'
If [[$ fdate <$ mydate]; then
Rm-rf $ file;
Else
Echo $ file;
Fi
Else
Fdate =$ {file: 12: 8}
Mydate = 'date + % Y % m % d-d "-7 day "'
If [[$ fdate <$ mydate]; then
Rm-rf $ file;
Else
Echo $ file;
Fi
Fi
Done
View table fields
Su-oracle <BO
Sqlplus/as sysdba <EOF
Desc user_tables;
Exit;
EOF