Shell Script-1

Source: Internet
Author: User

.: Denotes any character

*: Matches the previous character, A * indicates: 0 or more A

+: Matches the preceding character to represent 1 or more preceding characters

?: matches the preceding character to represent 0 or more preceding characters

#! /bin/bash #!/bin/sh Opening

Comments:

: <<! Eof!

Write code here

! Eof!

Can be the SH 1.sh to execute the script, or the right to chmod a+x 1.sh and then./1.sh

Sh-x: Can be used to debug scripts

Date +%y: Year (M-month, D-Day, H-hour, M-minute, S-second, s = number of seconds from January 1, 1970 to present, W week, W is now the first week)

Date-d " -1day" + "%F%T": Indicates this time of yesterday

Export can declare global variables, which can take effect in child shells

$: script itself

$#: The script uses several parameters

$n: Represents the nth parameter

If

Format: note [] There are spaces on both sides

if Conditions

Then

echo "true";

elif [condition]; then

echo "false";

Else

echo "Error";

fi

>:GT, <:it, >=:ge, <=:le, ==:eq,!=:ne

-a means that &&,-o represents | |

If determine file, directory properties
[-F file] Determines if it is a normal file, and there is
[-D file] Determines if it is a directory and exists
[-E file] to determine whether files or directories exist
[-R File] to determine if the document is readable
[-W file] Determines whether the file is writable
[-X file] Determines whether the file is executable

exec >/tmp/$d. Log 2>&1: You can append the actual error to the/tmp/*.log

Generally written on top of the script, you can output all the logs executed by the script

when a variable is defined n=1 do not add spaces on either side of the equals sign

June 15, 2015

By:champly

Shell Script-1

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.