Shell exam primary articles

Greater than 10K to transfer files in the current directory to the / tmp directory

find . -type f -size +10k -exec mv {} /tmp \;

 

Write a shell, entered by the user to determine whether the file is a character device file. If so, please copy it to the / dev directory

! # / bin / the bash 
Read -t 30 -p ' Please The Output File you specified: ' str1 
# reads the input from the user 

IF [-n $ {str1}] && [- E $ {str1}]; 
# Analyzing file the authenticity of 
  the then 
    str2 = $ ( LS - L str1 $ {}) 
    Str3 = $ {str2: 0 : . 1 }
     iF [$ Str3 == " C " ]; 
    if the file is a block device # Analyzing 
      the then 
    Music Videos $ str1 / dev /
     fi 
  the else 
    echo  " the Input IS Wrong. " 
fi

 

Please explain the meaning of the underlying meaning of the default script in the comment line

#!/bin/sh
# chkconfig: 2345 20 80
# /etc/rc.d/rc.httpd
# Start/stop/restart the Apache web server.
# To make Apache start automatically at boot, make this
# file executable: chmod 755 /etc/rc.d/rc.httpd
case "$1" in
'start')
/usr/sbin/apachectl start ;;
'stop')
/usr/sbin/apachectl stop ;;
'restart')
/usr/sbin/apachectl restart ;;
*)
echo "usage $0 start|stop|restart" ;;
esac
Please explain the script comment line with the underlying meaning of the meaning of the default 
interpreter specified script file: The first line 
of the second line: Specifies the run level script file in the program chkconfig, 2345 on behalf of a specific user mode (available ' - ' instead of ), represents the start of the 20 priority 80 representatives stop priority. The lower the number the more priority is executed first 
third line: tell the user script file should be stored Road King 
fourth line: tell the user boot methods and the use of start of 
the fifth row: Description of simple scripting services for 
the sixth line: file extended perform operations

 

Write a simple shell add up to 10 users, with user name beginning

 

#!/bin/bash
for i in `seq 1 10`;
  do
    useradd user${i}
  done

 

 

Write a simple shell deleting 10 user, the user name begins with the user

 

#!/bin/bash
for i in `seq 1 10`;
  do
    userdel -r user${i}
  done

 

Write a shell, all the contents of the backup and compression / etc directory, stored in / tmp / directory and file name of the form yymmdd_etc.tar.gz

#!/bin/bash
NAME=$(date +%y%m%d)_etc.tar.gz
tar -zcf /tmp/${NAME} /etc

 

Guess you like

Origin www.cnblogs.com/guge-94/p/11540238.html