Fortune Telling Collection - Fortune-telling birth date - Linux addition, subtraction, multiplication and division commands Linux addition and subtraction
Linux addition, subtraction, multiplication and division commands Linux addition and subtraction
Sum the numbers in the first column: awk "{a+= $1} end {printa}"
Sum the numbers in the second column: awk "{a+= $2} end {printa}"
Send through the pipeline: echoXXX|awk
Or awk reads the file.
What is the sum of linux 1 to 100?
The sum of 1 to 100 is 5050. What is the sum of 1 to 100? Take the following methods: Ask this question and you can get the sum of 1 to 100. You can add the first 1 to 100, 1+ 100 equals1kloc-0/,and then go.
Linux network operating system problems, first, write shell scripts to achieve addition, subtraction, multiplication and division. There is no limit to the implementation method, but try to reduce the probability of mistakes?
setd = 0;
if
then
Echo $3
d=$(($ 1-$2))
The ship does not bear the loading fee.
Echo $ TERM
What are the common linux commands?
Linux is an indispensable system for our developers, and it is often contacted. However, there are many commands in Linux, some of which are not commonly used and are difficult to remember. So, how to use Linux commands more efficiently without having to study comprehensively? Today, I will share with you some common and practical Linux commands that I used in the development process.
0 1 View file or log
Check the file content or log file, I believe almost everyone will come into contact with it. Among them, the most commonly used commands are head, tail and cat.
1, head
Represents the head and looks at the first few lines of data.
Headtest.log:test.log: the first few lines of the log content in the test. Log file.
Head-n20test.log: View the first 20 lines of log contents in the test.log file.
Head-n-20test.log: View the test.log except the last 20 lines of the log.
2. Tail
Represents the tail, viewing the last few lines or real-time logs.
Tail-ftest.log: View the log contents of the last few lines of the test.log file in real time.
Tail-f-n20test.log: View the last 20 lines of the log in the test.log file in real time.
Tail-n20test.log: View the last 20 lines of the log in the test.log file.
Tail-n+20test.log: View all log contents after 20 lines in the test.log file.
3. cats
Used to view the contents of a file.
Cattest.log: View all the contents of the test.log file.
02 local replication
It is also common to copy files or directories between different directories on the same server.
1, copy file
Cptest.log/home/geshan/logs: copied the test.log file to the /home/geshan/logs/ directory.
Cptest.log/home/geshan/logs/cptest.log: copied the test.log file to the /home/geshan/logs/ directory and renamed it cptest.log
Step 2 copy the folder
Cp-rlogs//home/geshan/: Copy the logs directory and all files in this directory to the /home/geshan/ directory, where there will be a logs directory.
CP-rlogs//home/geshan/test logs/: copy the logs directory and all files under it to the /home/ge shan/ testlogs/directory, and rename the logs directory as testlogs, provided that there is no testlogs directory under the/home/geshan/directory.
Note: -r or -R indicates a loop, which loops all files and directories in the directory. The same is true for all the following commands.
03 remote replication
When we need to copy files or directories from a remote server to a locally logged-in server, most people will think of logging in to the remote server to download files first, then logging in to the local server to upload files. This is more troublesome and inefficient.
1. Replication from local server to remote server
(1) Copy file
Command 1:
Scplocal _ fileremote _ user name @remote_ip:remote_folder
Command 2:
scplocal _ file remote _ username @ remote _ IP:remote _ file
Command 3:
scplocal _ file remote _ IP:remote _ folder
Command 4:
scplocal _ file remote _ IP:remote _ file
No. 1, No.2 specifies the user name, and the user password is required after the command is executed. No. 1 only specifies the remote directory, and the file name remains unchanged. The second specified file name; The third and fourth user names were not specified. After the command is executed, it defaults to the current server user name, and a user password is required. The third one only specifies the remote directory, and the file name remains unchanged. The fourth specifies the file name.
Example 1: copy the test.log from the local server to the /home/geshan/ directory of192.168.130 server and rename it.
20 190 125.log
Command:
Example 2: copy the test.log from the local server to the /home/geshan/ directory of192.168.130.130 server.
Command:
(2) copy the directory
Command 1:
scp-r local _ folder remote _ username @ remote _ IP:remote _ folder
Command 2:
Scp-rlocal _ folderemote _ IP: remote folder.
No. 1 Specify the user name, and the user password is required after the command is executed; The user name is not specified in the second one, so you need to enter the user name and password after the command is executed.
Example: /home/geshan/ directory command to copy from tomcat directory in the local server /home/appuser/ directory to192.168.130 server:
2. Copy from remote server to local server
The scp command copied from remote to local is the same as the above command, as long as the last two parameters of the command copied from local to remote are reversed.
(1) Copy file
Example:
Copy the test.log file from the /home/geshan/ path of the remote server at192.168.130 to the /home/appuser/ path of the local server.
Command:
scproot @ 192. 168. 130. 130:/home/ge shan/test . log/home/appuser/
(2) copy the directory
Example: copy the tomcat folder from the /home/geshan/ path of the remote server to the /home/appuser/ path of the local server at 192. 130.
Command:
Note: There is no space between the ip address and the path (that is, between colons), otherwise an error will be reported. The first time you communicate with another service (such as copying files), you will be prompted whether to trust it. As long as the input is yes.
04 compression and decompression
Compressing and decompressing files is also common. If you download all the files in a directory, you can download the directory directly, but if you download the directory directly, once there are many files, you will easily lose the files during the download process and the download speed will be slow. Usually, folders are compressed before downloading. There are four kinds of compression and decompression commands.
1, tar command
Decompression:
Compression:
Example: Unzip log.tar file:
Compress the log directory and name it log.tar:
2, gz command
Compression:
Note: The source file is compressed into. The gz file will disappear. If you want to keep the source file, use the following command.
Decompression:
. Tar.gz and. Tgz decompression:
Compression:
Compress multiple files:
Example: Decompression of tomcat.tar.gz Files
Compress the tomcat directory and name it tomcat.tar.gz file.
3.zip command
Decompression: unzipfileName.zip compression:
Note: When compressing the directory, you need to add -r, which means that all files and directories in the directory will be recycled. When compressing multiple files or directories, spaces are required between the files or directories.
Example: extract the log.zip file:
Compress the log file directory and name it log.zip:
Compress the log 1 and log2 directories and name them log.zip:
Compress the files test 1.log and test2.log and name them log.zip:
4.rar command
Similarly, similar to the zip command, just change zip to rar.
05 modify permissions
The access rights of files and directories in Linux system are different. In some ways, we can determine who can manipulate files and directories accordingly.
Among them, the access rights of files or directories are divided into read-only, write-only and executable, which represent readable, writable and executable respectively.
1, chgrp command
Change the group to which a file or directory belongs. Command:
Example: change the group to which the test.log file belongs to the Geshan group.
Change the log directory and the group to which all files in the directory belong.
2.chown command
Change the user to which a file or directory belongs. Command:
Example: Change the user of the test.log file to geshan user.
Change the users of logs directory and all files in this directory to Geshan users.
3.chmod command
Used to change the access rights of a file or directory. Users use it to control access to files or directories. Command:
Among them, mode has many meanings, and only the numbers are explained below. Most people see that mode has permissions such as 777 or 776. What do these mean?
For convenience, the mode is changed to abc, where a, b, and c are each a number, respectively representing the rights of users, groups, and others. R=4, w=2, x= 1, R stands for reading, W stands for writing, and X stands for execution.
Rwx attribute 4+2+1= 7;
To rw- attribute, 4+2 = 6;
For the r-x attribute, 4+ 1=5.
Example: modify the test.log file to read/write (i.e. 777).
Modify the log directory and all files in the directory to read and write (666).
Enter LL (two lowercase ll) in Linux system. If a file or directory has 777 (read and write execution) permissions, you can see that the first one is -rwxrwxrwx. If it is 666 (read and write) permission, you can see that the front is -rw-rw-rw.
Note: generally, the permission to modify a file or directory needs to be modified by the super user (root), otherwise it may be reported that the permission is insufficient.
These Linux commands are commonly used and practical, and will certainly be useful. If it helps you, remember to like the collection and forwarding!
- Related articles
- Korean star fortune-telling douban stickers _ Korean star fortune-telling stickers douban
- Teacher Zhang told Fortune.
- Fortune-telling posture
- Jokes are unlimited! Ghost story! Paranormal phenomenon! ! ! !
- Eight-character fortune-telling software free download free _ eight-character fortune-telling software free download free use.
- Where is the black water filled?
- Fortune-telling stranger _ Can fortune-telling strangers play mobile phones?
- I wonder if I can die? It is better to have a fortune teller.
- The origin of Ge surname? Who are the celebrities in the history of Ge surname?
- What does Huo mean?