[ORIGINAL CREATION] BASH tips


####

The BASH and Bourne shell has a poorly documented feature that its termination status is 128 plus the signal number.

####
2>&1   means descriptor 2 is a copy of descriptor 1.  dup2(1, 2);

exec 3>&1                              # Save current "value" of stdout.

ls -l 2>&1 >&3 3>&- | grep bad 3>&-    # Close fd 3 for 'ls' and 'grep'.

exec 3>&-                              # Now close it for the remainder of the script.

####
stty tostop
Disable ability of background jobs to output to controlling terminal.

####
ls 有一个 F 选项哦

####
ln -s /some/dir .
把/some/dir下的所以文件软链接到当前目录  

####
$command 5<>tmp
The clause 5<>tmp opens the file tmp for reading & writing on file descriptor 5.

####
 if [ `pwd` == "$LOG_DIR" ]
pay attention to the blanks between every element of the statement.

####
$*  

All of the positional parameters, seen as a single word

$@ 

Same as $*, but each parameter is a quoted string, that is, the parameters are passed on intact, without interpretation or expansion. This means, among other things, that each parameter in the argument list is seen as a separate word.


####

#!/bin/bash

# Using 'shift' to step through all the positional parameters.

 

# Name this script something like shft,

# and invoke it with some parameters, for example

# ./shft a b c def 23 skidoo

 

until [ -z "$1" ]  # Until all parameters used up...

do

 echo -n "$1 "

 shift

done

 

echo   # Extra line feed.

 

exit 0

#####

if [ -n "$1" ]

# Test if command line argument present (non-empty).


####

select vegetable in "beans" "carrots" "potatoes" "onions" "rutabagas"

do

 echo

 echo "Your favorite veggie is $vegetable."

 echo "Yuck!"

 echo

 break  # if no 'break' here, keeps looping forever.

done

If [in list] omitted, so 'select' uses arguments passed to function.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值