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 are executed in that order.
PATH
You can set your PATHenvironment variable to tell the shell where to search for programs (and scripts)
to be run. The main system commands are in /bin, /usr/bin, /sbin, and /usr/sbin, but you may
have your own scripts in $HOME/bin, $HOME/scripts, /usr/local/bin, or elsewhere. Append these to
the PATHso that they will be found by the shell even when you are not in that directory:
PATH=${PATH}:${HOME}/bin
ls aliases
Because it is such a common command, there are a few popular lsaliases, the two 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=”:pwd: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 $0"
echo "I was called with $# parameters."
count=1
while [ "$#" -ge "1" ]; do
echo "Parameter number $count is: $1"
let count=$count+1
shift
done

$ ./manyparams.sh one two 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

生成序列的方法:
seq 10 -1 1
seq 1 1 10
seq last
seq first incr last
seq first last
生成随机数的方法:
$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
#(())表示数学运算
return $(($RANDOM % $RANGE +$MIN))
}
getrand 1 1000
#$?表示返回值
echo $?

if 判断中常用的一些表达式:
-d :判断制定的是否为目录
-z:判断制定的变量是否存在值
-f:判断制定的是否为文件
-L:判断制定的是否为符号链接
-r:判断制定的是否可读
-s:判断存在的对象长度是否为0
-w:判断制定的是否可写
-x:判断存在的对象是否可以执行
!:测试条件的否定符号

time format
 echo $(date "+%Y%m%d %H:%M:%S")

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的更多相关文章

  1. 【转】linux shell实现随机数多种方法(date,random,uuid)

    在日常生活中,随机数实际上经常遇到,想丢骰子,抓阄,还有抽签.呵呵,非常简单就可以实现.那么在做程序设计,真的要通过自己程序设计出随机数那还真的不简单了.现在很多都是操作系统内核会提供相应的api,这 ...

  2. Bash For Loop Examples for Your Linux Shell Scripting--ref

    There are two types of bash for loops available. One using the “in” keyword with list of values, ano ...

  3. Linux shell下30个有趣的命令

    Tips 原文作者:Víctor López Ferrando 原文地址:30 interesting commands for the Linux shell 这些是我收集了多年的Linux she ...

  4. Random number

    Original #include <stdlib.h> #include <time.h> srand(time(NULL)); rand(); The versions o ...

  5. Linux Shell系列教程之(十四) Shell Select教程

    本文是Linux Shell系列教程的第(十四)篇,更多Linux Shell教程请看:Linux Shell系列教程 在上一篇文章:Linux Shell系列教程之(十三)Shell分支语句case ...

  6. Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)

    How do I increase the maximum number of open files under CentOS Linux? How do I open more file descr ...

  7. linux shell编程总结

    linux shell编程总结 本周学习了unix/linux shell编程,参考的是<LINUX与UNIX Shell 编程指南>,David Tansley著:徐焱,张春萌等译,由机 ...

  8. linux shell命令之wc/split及特殊字符

    [时间:2018-07] [状态:Open] [关键词:linux, wc, split, 通配符,转义符,linux命令] 0 引言 整理这篇文章的目的不是为了什么学习,仅仅是为了强化下记忆,以便下 ...

  9. Linux Shell基础(下)

    Linux Shell基础(下) 目录 一.shell特殊符号cut命令 二.cut.sort.wc.uniq命令 三.tee.tr.split命令 四.简易审计系统 五.fork, exec, so ...

随机推荐

  1. 详细介绍ASP.NET页面间数据传递的使用方法

    源码:http://www.jinhusns.com/Products/Download/?type=xcj 在ASP.NET中,页面间数据传递的方法有很多.下面为大家总结一下,页面间数据传递的方法. ...

  2. .NET Core的“dotnet restore”、“dotnet build”和“dotnet run”命令都是用来干什么的?

    dotnet restore 源代码:https://github.com/dotnet/cli/tree/rel/1.0.0/src/dotnet/commands/dotnet-restore 入 ...

  3. windows 7文件误删shift+delete后找回

    昨天要还电脑了,结果脑子一抽,某个目录还没拷贝,shift+delete了整个目录,删除到一半,完了...我的源码都在里面还没出来啊...这TMD要命啊... 赶紧搜了一把,windows文件误删恢复 ...

  4. 初识HTTP协议

    本篇文章从概念上初识HTTP协议,参考链接:http://www.runoob.com/http/http-tutorial.html 目录: 一.HTTP协议    HTTP 工作原理    HTT ...

  5. 浅谈React受控与非受控组件

    背景 React内部分别使用了props, state来区分组件的属性和状态.props用来定义组件外部传进来的属性, 属于那种经过外部定义之后, 组件内部就无法改变.而state维持组件内部的状态更 ...

  6. Q:解决每天第一次打开MSCRM系统展示慢的问题

    问题:第天第一次打开系统时,需要加载很长时间,基本为1分多钟,而第二次打开只需5秒. 解决方案:利用IIS中的Session. 一.打开IIS,选择打开服务器功能中“Session State”. 二 ...

  7. CRM2013版本 IOS APP 说明(IPhone、IPad)

    CRM2013版本 IOS APP 说明(IPhone.IPad) IPhone版本 首页 CRM APP在登录时输入账号信息,可以进行首面.其首页显示内容可以在CRM后台设置. 系统默认显示:Pho ...

  8. 我在用的mac软件(2)-终端环境之zsh和z(*nix都适用)

    继续上篇介绍我的终端环境.这篇介绍zsh和z,其实这不局限于os x,在所有的*nix系统中都是可用的. zsh zsh作为bash的替代品,自然很多人要问:why zsh? 在Zsh Worksho ...

  9. 【转】Android中处理崩溃异常

    大家都知道,现在安装Android系统的手机版本和设备千差万别,在模拟器上运行良好的程序安装到某款手机上说不定就出现崩溃的现象,开发者个人不可能购买所有设备逐个调试,所以在程序发布出去之后,如果出现了 ...

  10. 斯坦福iOS7公开课4-6笔记及演示Demo

    1.变量类型别滥用id,如果不仔细容易在程序执行时引发错误,因为在编译阶段编译器只是检测变量对象所属类型,尤其是类型为id时代表任何类型都可以通过检查,但不会检测变量对象调用的方法,这样当对象所属类不 ...