The shell gets the names of all the folders under the directory and outputs

Gets the names of all the folders under the specified directory/usr/and outputs:Shell code:1#!/bin/Bash2 #方法一3 dir=$(ls-l/usr/|awk '/^d/{print $NF}')4 forIinch$dir5 Do6 Echo$i7 Done 8 #######9 #方法二Ten for dir inch$(ls/usr/) One Do A[-D

Use of shell scripts---while loop

While loop: Tests a condition repeatedly, as long as the condition is set up and executed repeatedlyThe condition can be: test the expression, or the Boolean value true (the condition is always true) and false (the condition is always false)vi

Command Shell to learn

For i in a B CDoEcho $iDone!ser Historical complements> Correct information output file>> correct information output file, append2> error message output file2>> error message output file append&>> all outputsfree-m | Grep-i Mem | awk ' {print $4,$3}

Linux-based shell programming (4)-for loop

For loopUsage:forindo 循环体doneSo how do you build the list?{1..100}This will generate the list.===========================================Cases:#!/bin/bash#forin {1..100};do echo$IdoneSeqYou can also generate lists with the SEQ commandUsage:seq

shell-0. Brief introduction

Shell-0. Introduction1. Use shell scripts in those environments• Application environment: Several complex parameters are required to execute certain commandsRequires multiple commands for State view and maintenance management of the systemRegular

Shell scripts define references to variables and environment variables

First, define variablesWhen defining a variable, the variable name does not have a dollar sign ($), such as:Variablename= "Value"Note that there can be no spaces between the variable name and the equals sign, which may be different from any

Shell Scripting Learning notes-looping structure

1. For loop statements1.1. Syntax Format:For Var in listdo Commandsdonefor ((expression)) do Commandsdone1.2 Simple example:#!/bin/sh# read echo from the direct list "read from direct list" for Var in 1 2 3do echo "$var" Doneecho "\ n"

Shell script programming Getting started to abort

1 Case-sensitive UNIX is case-sensitive, so shell scripts are case-sensitive 2 special characters Some characters of Unix have special meanings or functions that must be escaped if they are not used in their special sense (escaped). In order to

Linux shell Script Learning Note one

First, file comparison operators-e filename true if filename exists [-e/var/log/syslog]-D filename True if filename is a directory [-d/tmp/mydir]-F filename True if filename is a regular file [-f/usr/bin/grep]-L filename True if filename is a

Shell script collection system CPU, memory, disk, network information

A lot of friends do not know how to use shell scripts to collect information about the Linux system, including CPU, memory, disk, network and other information, here the script to do a small part of the explanation, we come together to see it.First,

Shell awk command string concatenation

The content of this section:The awk command implements the concatenation of stringsEnter the contents of the file:Tmall_inventory_30_group my163149.cm6 3506 5683506 mysql-bin. 000013327359057 tmall_inventory_31_group my163149.cm6

Shell Learning Essays

Cat/dev/null > FileName Empty file information Trash, the data sent to the secondary file will be deleted. W.H.O. | Wc-l calculating the number of users | (pipeline) can be two more programs between the establishment of a pipeline pipe:who output

Shell------randomly generate three-digit numbers

write a script to generate a random 3-bit number, and can be based on the user's input parameters to determine the output of a few groups. For example, the script name is number3.sh. Execution Method:Bash 2.shproduces a set of 3-digit numbers

Shell simple Use (-) judgment

Take a few simple examples of the judgments involved1. Comparison of file-related judgments#!/bin/Bashif[$#-lt1 ] Then Echo "No file name"Exit1elif[-D $1 ] Then Echo$1is directoryelif[-B $1 ] Then Echo$1is block deviceelif[-

Shell shares the LS command

Common Options list all files under the directory contain hidden files ls-a list file properties and sort by modified ls-lt list file attributes and sort the file's most recent read time LS-LTU list file attributes and sort files by file size Ls-ls

Shell Share mkdir command

The common options directory is present without an error (at this time there is no effect on the directory), there is the creation of mkdir-p, if there is a need to create a parent directory when creating a directory when the parent directory is

Shell string Equality Comparison, note the processing when the string is empty

if ["$test" x = "Test" x]Here are a few key points:1 with a single equals sign, two equals signs can be2 Note that there is a space on each side of the equal sign: This is the UNIX shell requirement3 Notice the last X of "$test" X, which is

Linux Shell expr uses

Linux shell expr use collectors: Spring and Autumn hundred flavor the-Geneva- +|read: Go:| |share non-original, excerpt from: "Linux and Unix Shell Programming Guide"17.5expr Usage The expr command is generally used for integer values, but can also

Linux Shell ls-1 column display file

spl

/******************************************************************************* * Linux Shell Ls-1 Column Display file * Description: * Sometimes when writing shell scripts, it is often necessary to list the files in a column, and then the * for

Linux Shell abs--Special characters

The special characters are as follows: "#"--Comment, beginning with # at the beginning of the line (#! is an exception).“;” --the command delimiter, which can be used to write multiple commands on a single line.“;;” --Terminates the "case" option.“.”

Total Pages: 541 1 .... 295 296 297 298 299 .... 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.