The magical application of ${} in the shell

1. Truncation function file=dir1/dir2/dir3/my. file.txt ${file #*/}: Remove the first/its left string: dir2/dir3/my. file .txt${ file ##*/}: Take out the last/and left string: my.file .txt${ file #*.}: Take out the first. and its left string:

Replacement in the shell

If there are some special characters in the shell, you need to replace them, you can do command substitution, variable substitution, escape substitution1. Substitution of escape charactersThe shell contains the following transfer characters\a Bell

Automatic IP modification of Linux shell scripts

#!/bin/sh#auto Change IP netmask Gateway scripts#wugk 2012-12-17Cat ++++++++ automatically modifies IP and host name information +++++++++Ethconf=/etc/sysconfig/network-scripts/ifcfg-eth0Hosts=/etc/hostsNetwork=/etc/sysconfig/networkdir=/data/backup/

Shell Step by Step (3)--stdin & IF

4. Input and output#! /bin/bash# Read users input and then get his nameread"Please input your first name: " firstNameread"Please input your last name: " lastNameecho-e"Your full name is: $firstName $lastName"Read usage:read[-ers][-a 数组][-d

WDCP Environment Build shell script Analysis--lanmp.sh---lib/common.sh

#common. SH, which is mainly some function # perform compiled cleanup work function make_clean {    # $RE _ins  based on the value of the variable, To determine whether to perform cleanup work     if [  $RE _ins == 1 ]; then         make clean >/dev/

Explanation of the meaning of "2>&1″" in the Linux shell script

The script is: nohup/mnt/nand3/h2000g  >/dev/null  2>&1 &  for & 1 more accurately said file descriptor 1, and 1 The general Representative is Stdout_fileno, which is actually a dup2 (2) call. He outputs the standard output to All_result, and then

Test command usage in shell syntax

The test command usage. Function: Check file and compare value 1) Judge the expression if test (expression is true) if test! expression is false test expression 1–a expression 22 expression is true test expression 1–o expression 22 expression has a

Bash Shell Basic Operation commands and environment variable commands (note)

First, the Bash Shell Basic Operations Command 1.type: See if the command is a built-in command of the Bash shell type cd2.Echo: The display of the variable echo $ variable echo name3.unset: Cancels the variable you just set unset name4.Envor SET

Shell scripts delete folders that are N days ago-----Different from the date command on Linux and Mac

Background:The items that are built daily are placed in different folders by date. As today's construction is put into 2015-06-01, tomorrow's will be put into 2015-06-02, and so on. Long time, need a script to delete the folder N days ago. (In this

Shell rewrite built-in command--CD

Introduction to the sceneUse Cygwin under Windows, use Apktool to repackage apk; Way OneCD D:CD path/to/apk/in/dApktool D name.apk Way TwoDrag the file into the Cygwin window to delete the trailing file nameCTRL + ACD SPACEApktool D name.apk Mode

Shell (BASH) programming

SHELL programmingDirectory:1.shell Brief Introduction2.shell Programming Preparation3.shell Programming Structured Language Building4. OtherTwo examples of 5.shell programmingWrite in front:1.Hello World#! /bin/bash# This is aexample of bash

A solution that writes HBase shell scripts on the SECURECRT terminal and cannot use the DELETE key

First, describeThe Linux system is connected remotely on the SECURECRT terminal, and the HBase shell script is used for distributed database operations, but you cannot modify the script that entered the error using the DELETE key.Second, the

Shell Programming---File testing and special variables

I. Arithmetic operations 1. Let arithmetic operation expressionLet c= $A + $B2. $[arithmetic operation expression]c=$[$A + $B]3, $ (arithmetic operation expression)c=$ (($A + $B))4, expr arithmetic expression, the expression in the operands and

Shell script programming (strict terminal format control, beautiful output font color)

#!/bin/bash# #下面是字体输出颜色及终端格式控制 # Font Color 30-37ECHO-E "\033[30m black word \033[0m" echo-e "\033[31m red word \033[0m" echo-e "\033[32m green word \ 033[0m "echo-e" \033[33m yellow word \033[0m "echo-e" \033[34m blue word \033[0m "echo-e" \033[35m

Shell copies files with similar file names to the specified file name in bulk

Problem:The directory structure is as follows:test/2001.01.01/2001.02.02/2001.03.02/2001.01.03/2001.02.04/2001.03.05/2001.01.04/2001.02.05/2001.03.07/2001.01.06/2001.02.06/2001.03.08/2001.01.12/2001.02.23/2001.03.09/2001.01.13/2001.02.26/2001.03.22/2

tiny4412 Serial drive analysis of nine---shell terminal

PengdonglinEmail:[email protected]Development Board: tiny4412adk+s700 4GB FlashHost: Wind7 64-bitVirtual machine: vmware+ubuntu12_04U-boot:u-boot 2010.12Linux kernel version: linux-3.0.31Android version: android-4.1.2In the above we know

Shell Judgments and comparisons

Http://blog.chinaunix.net/uid-7553302-id-183648.html1 Shell's $! , $?, $$,[email protected] $n The first parameter,$2 the second ... $# the number of command-line parameters. The name of the current program.

Special characters of shell scripts

Special characters of shell scripts1. # comment ,#! Besides, echo $ {PATH # *:} parameter replacement does not represent annotation, numeric conversion, and echo $(2 #101011) 2 .; command Line separator. Multiple commands can be written in one line.

Shell script programming (strict terminal format control, beautiful output font color)

Shell script programming (strict terminal format control, beautiful output font color) #! /Bin/bash # font output color and terminal format control # font color 30-37echo-e "\ 033 [30 m black character \ 033 [0 m" echo-e "\ 033 [31 m red word \ 033 [

Shell script programming (fast sorting), shell script programming sorting

Shell script programming (fast sorting), shell script programming sorting #! /Bin/bash # implementation of fast sorting in shell script programming (using the rightmost element as the element) a = (8 5 10 3 2 93 4 1 2 3 40 9 61 8 6 29) # a = (0 0 0 0

Total Pages: 541 1 .... 169 170 171 172 173 .... 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.