Common usage and examples of arrays in shell programming under Linux

A new version of Bash supports one-dimensional arrays. Array elements can be initialized using the notation variable[xx]. Alternatively, the script can use the DECLARE-A variable statement to specify an array, and so on. To refer to an array element

CPU load Monitoring script code _linux Shell

Copy Code code as follows: #!/bin/bash Load= ' uptime ' shijian= ' Date +%y-%m-%d-%t ' File=cpustatus.txt Touch $file All= ' Cat $file |wc-l ' printf "$load $shijian \ n" >> $file if [[$all > 60]]; ThenStarttime= ' cat

Common script and function sharing in Linux _linux shell

#查找当前目录中是否存在指定目录, if it does not exist, it is created Copy Code code as follows: function mkdir_1 { if test! -D $ Then mkdir $ Fi } #指定文件中的 "prefix =. *" string replaced with "prefix=/home/gnome-unicore-install2/usr/

Shell code that compares two strings for equality _linux shell

To compare two strings for equality: If ["$test" x = "Test" x]; Then Here are a few key points: 1 using a single equal sign 2 Notice that there is a space on each side of the equal sign: This is what the Unix shell requires 3 Notice the last X of "$

Shell traversal directory processing specific directory script code _linux shell

Requirements: Delete files, directory structure: ip/year/month, everyone has a copy of this directory now need to delete all files before 2012, 2012 after the deletion of a specific month.Originally wanted to use find, the results found that these

Linux under SSH installation and SCP command using the detailed _linux shell

The Ubuntu default does not have SSH service installed, which can be done with the following command: Copy Code code as follows: yblin@yblin-desktop:~$ ssh localhost Ssh:connect to host localhost Port 22:connection refused

Code to read and output data using shell commands _linux shell

The shell script reads data in several ways:1. keyboard input, default2. read from the file3. Pass through Pipeline command Functions of Echo:\c: No Line change\f: Paper Feed\ t: the jump Grid\ n: Wrapping Line\ represents escape, for example:

Linux shell array Deep learning understanding _linux shell

The bash shell supports only one-dimensional arrays, but there are no restrictions on the number of arguments.Declare an array:Declare-a Array(In fact, you don't have to declare that you can assign a value directly to a variable in an array, and

Get disk IO vs. system load load shell script _linux shell

1, extract the system load information Copy Code code as follows: #!/bin/sh host=$ (hostname) channel=$ (hostname | sed ' s/[0-9]//g ') runday=$ (Date +%y-%m-%d) iphost=$ (/sbin/ifconfig | grep ' inet addr: ' | grep-v ' 127.0.0.1 ' |

${in Shell}, # #和%% use example _linux shell

Today read a script file when there are some places do not understand, find an article to read some, feel good, keep down.Let's say we've defined a variable as: Copy Code code as follows: File=/dir1/dir2/dir3/my.file.txt You

Shell script implementation randomly generates 10 8-bit passwords _linux shell

Randomly generated 10 8-bit password shell scripts1. First Capital Letter2. Middle six-digit alphanumeric random mixing3. Eighth place [0-9] #!/bin.bash for i in {1..10} do a= ' head-c 500/dev/urandom | tr-dc a-za-z | tr [A-z] [a-z]|head-c 1

Linux shell script implements CPU alert _linux shell

The script that prints the Java thread occupancy stack is invoked if the CPU occupancy rate continues to reach more than 80, see https://github.com/oldratlee/useful-shells/blob/master/ Show-busy-java-threads.sh, see his GitHub wiki! in concrete

Shell script implements monitoring shell script execution flow and variable value _linux shell

Many times, we will write a shell program to complete some of the time without duplicating the wheel, but because the shell statement will also have functions, there will be variables, in the end after the implementation of what related operations,

Linux multithreaded Programming tutorial (thread through the semaphore to achieve communication code) _linux Shell

Thread classification Threads can be divided into user-level threads and core-level threads according to their dispatchers. (1) user-level threadsThe user-level thread mainly solves the problem of context switching, and its scheduling algorithm

Linux shell logical operators, logical expressions detailed introduction _linux shell

One, logical operators Logical Volume Label Express meaning 1. About the files and directories of the detection of logical labels! -F Common! Detect the existence of "archives" eg:if [-f filename]

Shell.Application simple function is called in the VBS _vbs

chr

Set os=createobject ("Wscript.Shell") Set os0=createobject ("Shell.Application") Todo Input1=inputbox ("Please select:" +CHR () +CHR (13) + _ "1. All Windows Minimized" +CHR (13) + _ "2. Window state Recovery" +CHR (13) + _ "3. Window evenly tiled" +

Android Execute shell Command detailed _android

First, the method Copy Code code as follows: /** * Execute a shell command and return the string value * * @param cmd * An array of command names & parameters (for example: {"/system/bin/cat", "/proc/version"}) * @param workdirectory

Examples of Linux shell script tests

Script 1: Write a login welcome script for root users: 1, with vi command in the/root directory is a new script file welcome.sh, the contents are as follows: 2, using the chmod command to welcome.sh file to increase the execution (x) permissions

Set font and background color under Linux BASH shell

Set font and background color under BASH shell\e[30m change the display color of a character to black\e[31m change the display color of a character to red\e[32m change the display color of a character to green\e[33m change the display color of a

Shell standard input, output, and error

Security code: Taohuatan depth thousand feet, less than mountain send Me love.File descriptor (FD): The file descriptor is a non-negative integer, and when you open an existing file or create a new file, the kernel returns aFile descriptors, and

Total Pages: 541 1 .... 129 130 131 132 133 .... 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.