Recently seen in the group sent a calculation, using the shell run without optimization, no algorithmTopic:A basket of eggs:A 1 to take, just to finish.2 2 and 1 left.3 3 Take it, just take it out.4 4 and 1 left.5 5 and 4 left.6 6 and 3 left.7 7
The IF in [] is actually called a quick method of test. Bash's numeric and string comparison operators:
Note = spaces on both sides
String
Numerical
is true, if
x = y
X-eq y
[email protected] ~]$ cat test1.sh#!/bin/bashecho "What is your operating system?"Select Os in "Linux" "Unix" "Mac" "Windows"DoBreakDoneecho "Your operating system is $os"[[email protected] ~]$./test1.sh #? Subsequent numbers require manual input by
For example, there is a file Test.txt, which contains this data.meiguounix232FaguounixRibenunixZhongguounixtaobaoHanguounixbabaNow I want to intercept Unix in front of the data, including UNIX, and output.The data to be obtained should
1:grep Command:Grep-v "char" file_name matches text that does not include "char"Grep-n-W "char" file_name complete match for a charactergrep ^s $s are text that matches the beginning of s or the end of the line as S.2:TR commandTR Set1 Set2 Replace
Output redirectionThe syntax for command output redirection is:Command > file or command >> fileIn this way, the contents of the output to the display can be redirected to the file. If you don't want the file content to be overwritten, you can use >>
Bash supports a number of operators, including arithmetic operators , relational operators , Boolean operators , string Operators , and file test operators .Native bash does not support simple math operations, which are string operations by default,
1. Regular expressionsIn fact, it is a specification, that is, the pattern, constraint string, and so on what kind of format, such as the requirement that the string must begin with a, t end, strings that meet such conditions will use the regular
Requirements:1. Display the current system date and time, and then create the directory/tmp/lstest2. Switch working directory to/tmp/lstest3. Create a directory A1d,b56e,6test4. Create an empty file xy,x2y,7325. list files or directories in the
Java suspended animation, but the process is still in, you can determine whether the log file changes over time to determine whether Java suspended animationThe shell script is as follows:#!/bin/bash# #通过比较五分钟前后, log file MD5 value is the same, to
Repeating a series of commands while running a script is common, and we need to use loop statements to do this.One, for commandFormat: for variable in list;Loop bodyDoneThe for command iterates through each value in the list and exits the loop after
The type of shell that stands on the user's point of view:Log-in Shell:Log in normally via a terminalSu-usernameSu-l usernameNon-landing shell:SU usernameOpen Command Window under graphics terminalShell scripts that are executed automaticallyBash
Enterprise Real Shell interview questions, a challenge to put!Statement: If there is a similar, purely plagiarism1. Develop a daemon script that executes every 30 seconds to check MySQL master-slave synchronization[email protected] scripts]# cat
In the process of learning Linux, have encountered some small problems, although may be insignificant, but in the pursuit of details often will be more tangled (obsessive-compulsive disorder), empty a blog post space, record some details on the
Freshman semester to learn the basic operation of Linux, has not been used for a long time, the virtual machine has not opened nearly half a year (as a computer professional juvenile really should not). To replenish this knowledge and lay the
Cat /etc/passwd All system user accounts list and basic information for each user cat/etc/meminfo the current state of the virtual memory ipcs-m View the Shared memory page on the current system [[email protected]~] #当前shell的用户名, current
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.