the diary of homework of script check dir in linux
2017-04-17 11:41
405 查看
to make a script to check a directory?
#!/usr/bin/bash#check the information of a directory
#Asha 2017/4/17
if [ ! -d $1 ]
then
echo there is no this directory.
exit
fi
echo we have `ls -p $1 | grep '[^/]$' | sed 's/\s\s*//g' | wc -w` files inside this directory.
echo we have `ls -p $1 | grep '[/]$' | sed 's/\s\s*//g' | wc -w` directories inside this directory.
echo the biggest file `ls -l
$1| tail -n +2 | sed 's/\s\s*/ /g' | cut -d ' ' -f 5,9 | sort -n | cut -d ' ' -f 2| tail -1`.
echo the latest modification file or directory is `ls -l -t$1| tain -n +2 | head -1`.
echo the owners of files or directories inside this directory is/are `ls -l $1 | tail -n +2 | sed 's/\s\s*/ /g' | cut -d ' ' -f 3 | uniq`.
相关文章推荐
- the diary of script in linux
- the diary for one command application of pipe in Linux
- the diary of how to backup one more files in linux
- the diary of pipe in linux
- How to check the usage of net ports in linux?
- the diary of sleep jobs & fg command line in linux
- Check the available of yum in Linux
- Check the bits in linux
- Getting over the dangers of rm command in Linux---reference
- How to check the external public IP in linux
- 奇葩问题:This file could not be checked in because the original version of the file on the server was moved or deleted. A new version of this file has been saved to the server, but your check-in comments were not saved
- Perl script to check the length of a file
- Getting over the dangers of rm command in Linux---reference
- Understand the boot-up procedure of Linux in Depth
- How to write a shell script to check the return value of main()
- the connection to the VMware USB Arbitration Service was unsuccessful.Please check the status of this service in the Microsogt M
- Problems during startup. Check the".log" file in "metadata" of your workspace.
- the implementation of system call in linux
- Misleading error message in PowerShell script: "Invalid assignment expression. The left hand side of an assignment operator need
- [Script]Check status of all the Concurrent Managers