Shell for and if multi-condition instances

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

Shell command--if

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

Shell's SELECT statement

[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

"Shell" intercepts the text in front of a string

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

Shell programming text and log filtering

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

Shell Road "Fourth" input and output redirection

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 >>

The "second" operation of the Shell Road

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,

Shell Programming-Conditional judgment

There are 6 main types of conditional judgments:[Email protected] test]# Ls-ltotal 8drwxr-xr-x 2 root root 4096 Jan 19:28 shell-rw-r--r--1 root root 4 Jan 17 19 : Test.sh[[email protected] test]# [-D test.sh] && echo "Yes" | | echo "No" no[[email

The regular expression of shell programming

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

Shell---Practice4

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

Shell determines if the file has changed

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

Shell Script Programming Loop statements

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

Linux_ Shell configuration file for user perspective

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

All those years we've been together. Shell face questions (I.)

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

Shell Programming advanced 1.5 if logic judgment

Logical judgmentif. sh#!/bin/bash### #a=5if3 ]then "a>3" fiif. shA>3Vim if2.sh#!/bin/bash### #a=5if3 ]then "a>3"Fiif 4 ]then "a>4"fiif2. ShSH if2.sh>-ge greater than= =-eq equals! =-ne Not equal to>=-ge greater than or equal toVim

Shell Operation details finishing (not completed)

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

Linux Shell Common commands daily one more

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

Shell--awk

1. awk command format: awk [Options] File name Options -F FS: Specify delimiter for split data -F File: Specifies the program's script file Example: awk-f: ' {print '} '/etc/passwd Awk–f script/etc/passwd Script: Represents

Shell Auto-Configure Bond

#!/bin/bash# automatic configuration Bond#by liuqmodprobe= "/sbin/modprobe" cd /etc/sysconfig/network-scripts if  [ -f ifcfg-eth0 ]thencp ifcfg-eth0 /tmp/ifcfg-eth0.bakcp ifcfg-eth1 /tmp/

Linux Shell Notes

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

Total Pages: 541 1 .... 534 535 536 537 538 .... 541 Go to: GO

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.