shell programming exercises

  1. 2 and the number of seek
  2. 1-100 and computing
  3. The extension of all files under a directory to bak
  4. Compile all current .c files in the directory under:
  5. Print root can use the executable file count, and the results: root's bins: 2306
  6. Print sshd port and process id, process results: sshd Port && pid: 22 5412
  7. Output of the local directory creation time 20000 used, processing results:

real    0m3.367s

user    0m0.066s

sys     0m1.925s

  1. Swap partition size, print processing result of the machine: Swap: 1024M
  2. Text analysis, the number of extraction / etc / password in the shell occurring

The first method results:

    4  /bin/bash

    1  /bin/sync

    1 / sbin / halt

    31 /sbin/nologin

    1  /sbin/shutdown

The second method results:

/bin/sync       1

/bin/bash       1

/sbin/nologin   30

/ Sbin / halt 1

/sbin/shutdown  1

  1. Filing, employee files recorded in the job number and name, bonus file record number of workers and wage demands to merge the two files and output as follows, and the results :( prompt join)

400 ashok sharma $1,250

100 jason smith  $5,000

200 john doe  $500

300 Sanjay Gupta $ 3,000

 

employee.txt:

100 Jason Smith

200 John Doe

300 Sanjay Gupta

400 Ashok Sharma

bonus.txt:

100 $5,000

200 $500

300 $3,000

400 $1,250

  1. Write a shell script to get the current date, time, user name and current working directory.
  2. Writing shell scripts obtain the network address of the machine.
  3. Write a shell script to transfer files larger than 10K in the current directory to the / tmp directory
  4. Write a script called myfirstshell.sh, which include the following.

a) contains a comment that lists the purpose of your name, the name of the script and write the script.

b) greeting customers.

c) date and time.

d) show this month calendar.

e) to display your machine name.

f) displays the name and the current version of the operating system.

g) A list of all files in the parent directory.

h) show all processes running root.

i) show that the variable TERM, PATH and the HOME.

j) displaying disk usage.

k) with the id command to print out your group ID.

m) with the user says "Good bye"

  1. Copy file movement, there m1.txt m2.txt m3.txt m4.txt, respectively, to create the corresponding directory, m1 m2 m3 m4 and move the file to the corresponding directory.
  2. Today the root user login how long
  3. A file name input terminal to determine whether the device file
  4. Statistics IP access: requirements analysis apache access log to find out the number of IP access number 100 of the front page. Log size is about 78M. The following is an excerpt apache access log

202.101.129.218 - - [26/Mar/2006:23:59:55 +0800] "GET /online/stat_inst.php?pid=d065 HTTP/1.1" 302 20-"-" "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"

  1. Shell design a program established under / userdata directory 50 directory, namely user1 ~ user50, and set permissions for each directory, where the permissions for other users: Read; file owner permissions are: read, write, execute; permission for the file owner's group: read, execute.
  2. Design of a shell program, to add a new group Class1, then add 30 belong to this group of users, in the form of a user name is stdxx, where xx from 01 to 30, and set a password corresponding stdxx.
  3. Writing shell programs automatically delete 30 accounts function. Account named std01 to std30.
  4. Users to clean, remove the machine for all users except for the Current User
  5. Design a shell program, backed up in the first day of each month and compress all the contents of / etc directory, stored in the / root / bak directory and file name, yymmdd_etc in the following form, yy for the year, mm for the month, dd is the day . Shell program fileback stored in the / usr / bin directory.
  6. For a user log file, each line recorded a user query string, a length of 1-255 bytes, a total of tens of millions of rows, prior to exiting the top queries 100. Logs can construct their own>. (Tip: awk sort uniq head)
  7. Write your own script to install ubuntu environment
  8. Write server daemon management script.

Guess you like

Origin www.cnblogs.com/wanghao-boke/p/11568733.html