Application Skills Series - (2)

zhaozj2021-02-17  89

Application Skills Series - (2) NULL of this site

Back to〗 Forward〗

Application Skills Series - (2) File Content Statistics and Comparison Command File Content Statistics and Comparison Command ■ File Content Statistics Command WC Command WC Command Function is the number of bytes, words, number of lines in the specified file, and display statistics Output. Syntax: WC [Options] File ... Description: This command counts the number of bytes, the number, and number of lines in a given file. If no file name is given, you are read from the standard input. The WC also gives the presidential count of all specified files. The word is the largest string separated by the space character. The commands all the options are as follows: - C statistics bytes. - L statistics number. - W Country number. These options can be used in combination. The order and number of output columns are not affected by the order and number of options. Always display in the following order and one column per item. The number of lines, words, bytes, file names If there is no file name in the command line, the file name does not appear. For example: $ WC - LCW File1 File2 4 33 File1 7 52 File2 11 11 85 Total omitted option - LCW, the execution result of the WC command is the same as above. ■ File Comparison Command This set of commands can be used to compare the differences in two file content. Comm command can use the Comm command if you want to compare two ordered files. Syntax: Comm [- 123] file1 file2 Description: This command is compared to two files that have already been ranked. Where File1 and File2 are already sorted files. COMM reads these two files, then generates three-column output: rows that appear only in File1; only rows appearing in File2; rows exist in two files. If the file name is "-", it means reading from the standard input. Options 1, 2 or 3 suppress the corresponding column display. For example, COMM - 12 is only displayed in two files; COMM - 23 is displayed only in the first file and does not appear in the second file; COMM - 123 does not display anything. For example: assuming $ cat myfile1 main () {float a, b, i, j, z; a = i = 10; b = j = j = j = j = j = j = j = j = j; printf (" Z =% d // n ", z);} $ cat myfile2 #include main () {float I, j, z; i = 10; j = 5; z = i j; printf (" z =% f // n ", z);} $ commit - 12 myfile1 myfile2 main () {z = i j;} Only lines in MyFile1 and MyFile2 are displayed. DIFF command The function of this command compares two text files, listing the differences. It completes more complex checks than the Comm command. It performs system checks for the files given and displays all different lines in two files, and no files are required in advance. Syntax: DIFF [Option] File1 File2 Description: This command tells the user that in order to match the two files File1 and File2, which rows need to be modified. If "-" means File1 or Fiie2, the standard input is indicated. If File1 or File2 is a directory, DIFF will compare the same name file in this directory. For example: DIFF / USR / XU Mine compares files named Mine in the directory / usr / xi to Mine files in the current directory.

It is usually outputted in the following form: N1 A N3, N4 N1, N2 D N3 N1, N2 C N3, N4 These rows Similar ED commands convert the Filel to FILE2. The line numbers (N1, N2) before the letters (A, D, and C) are for File1, and the line numbers (N3, N4) behind it are for FILE2. Letters A, D and C indicate additional, delete, and modify operations, respectively. After each line of the above form, followed by several rows that are affected, with the "<" of the leader belongs to the first file, and the line of ">" is a second file. DIFF can distinguish between blocks and character device files and FIFO (pipe files), which will not compare them with ordinary files. If File1 and File2 are directory, DIFF will generate a lot of information. If there is only one file in a directory, a message is generated, indicating the directory path name and the file names. The meaning of the DIFF option is as follows: - b ignores spaces of the row, and one or more spaces in the string are considered equal. If How are you and how are you are treated as the same string. - C uses the contextual output format (provide three-line context). - C N uses the context output format (providing N-line context). - E Produces a legal ED script as an output. - R When File1 and File2 are directory, recursively acts on each file and directory. For example, the content of the file ml.c is (the left line number is intentional, in order to front and rear control): 1 main () {Printf ("Hello! \N");} 5 files M2.c content is: 1 Main () 2 {3 INT N, M; 4 n = 10; 5 Printf ("% d // n", m = n * 10); 6} Enter command: $ DIFF m1.c m2.c screen display : 3, 5 c 3, 6 Printf ("Hello! \N");} <5> 3 INT N, M;> 4 n = 10;> 5 Printf ("% d // n", m = n * 10);> 6} Indicates that two files are identical after 3 to 5 rows of the file M1.c into M2.c.

============================================================================================================================================================================================================= ========= Modify the login screen to this machine: first modify file / etc / Issue to change the content to display, modify file /etc/rc.d/rc.local(Redhat) or / etc / Rc.d / rc.s (sletware) Note the following: # this will overwrite / etc / Issue at every boot. so, make any changes you # Want to make to / etc / issue here? When You reboot. echo ""> / etc / ipsue echo "Red Hat Linux $ R" >> / etc / ipsue echo "kernel $ (uname -r) on $ A $ (uname -m) >> / etc / Issue cp -f / etc / issue /etc/issue.net echo >> / etc / issue Otherwise, you will be changed every time you restart / etc / Issue. For the Telnet's remote machine: first change the file /etc/usr/sbin/in.telnetd, such as change to in.telnetd.exe, edit a shell script called in.telnetd, after displaying the content you need Then call in.telnetd.exe.

转载请注明原文地址:https://www.9cbs.com/read-31595.html

New Post(0)