Linux Shell get random number

Source: Internet
Author: User
Tags readline

The Shell profile:
When a new interactive shell is started,/etc/profile, followed BY/ETC/BASH.BASHRC (if a
Bash shell), ~/.profile, and finally ~/.BASHRC is executed in that order.
PATH
can set your pathenvironment variable to tell the shell where to search for programs (and scripts)
To is run. The main system commands is In/bin,/usr/bin,/sbin, And/usr/sbin, but may
There are your own scripts in $HOME/bin, $HOME/scripts,/usr/local/bin, or elsewhere. Append these to
The PATHSO that they would be found by the shell even if you were not at that directory:
Path=${path}:${home}/bin
LS aliases
Because It is such a common command, there was a few popular lsaliases, the most common
Being llfor ls-land lafor ls-a. Your distribution might even set these for you. Some Popular
Lsaliases include:
# Save Fingers!
Alias l= ' ls '
# Long listing of LS
Alias Ll= ' Ls-l '
# colors and file types
Alias lf= ' LS-CF '
# Sort by filename extension
Alias lx= ' LS-LXB '
# Sort By size
Alias lk= ' LS-LSR '
# Show hidden files
Alias La= ' Ls-a '
# Sort By Date
Alias lt= ' ls-ltr '

History:
# Append, don ' t overwrite the history
Shopt-s Histappend
# Control the size of the history file
Export histsize=100000
Export histfilesize=409600
# Ignore common commands
Export histignore= ":p wd:id:uptime:resize:ls:clear:history:"
# Ignore duplicate entries
Export Histcontrol=ignoredups
History

~/.INPUTRC AND/ETC/INPUTRC
/etc/inputrcand ~/.inputrcare used by GNU ReadLine facility (used by bash and many other
Utilities to read a line of text from the terminal-to-control how ReadLine behaves.
Set Completion-ignore-case on

Http_proxy = serveraddress
Proxy_user = Username
Proxy_password = password

Sample
echo "My name is basename $0-i was called as"
echo "I was called with $# parameters."
Count=1
While ["$#"-ge "1"]; Do
echo "Parameter number $count is: $"
Let count= $count +1
Shift
Done

$./manyparams.sh One and three
My name is Manyparams.sh-i was called as./manyparams.sh
I was called with 3 parameters.
Parameter Number 1 Is:one
Parameter Number 2 Is:two
Parameter Number 3 Is:three

Methods for generating sequences:
Seq 10-1 1
Seq 1 1 10
Seq Last
Seq First INCR last
Seq First Last
Methods for generating random numbers:
$RANDOM
Random produces a random number between 0 and 32767.
If you want to generate data between M...N, write a function
function Getrand ()
{
Min=$1
Max=$2
Let "range= $MAX-$MIN";
If ["$RANGE"-le "0"]; Then
echo "Error-max is less THAN MIN"
Fi
# (()) indicates a mathematical operation
Return $ (($RANDOM% $RANGE + $MIN))
}
Getrand 1 1000
#$? Represents the return value
echo $?

Some commonly used expressions in the If judgment:
-D: Determine if the set is a directory
-Z: Determine if the established variable has a value
-F: Determine if the document is set
-L: Determine if the set is a symbolic link
-R: Determine whether the formulation is readable
-S: Determines whether the length of the object exists is 0
-W: Determine if the formulation is writable
-X: Determines whether an existing object can be executed
! : Negative symbol for test condition

Time format
echo ${date +%y%m%d}

Ifs
IFS is the Internal Field separator:it lists, the set of characters that may be used as whitespace. Its
Default value is <space><tab><newline>
ifs=$ (Echo \t\n)

Linux Shell get random number

Related Article

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.