---
title: "shell小结(15)"
author: "venceinfo"
date: "2010-02-09T15:33:44Z"
tags: ["Bash", "F#"]
categories: ["非技术"]
slug: "shell-15"
draft: false
lastmod: "2010-02-09T15:33:44Z"
id: 592327
url: "https://venceinfo.iteye.com/blog/592327"
---

```
#!/bin/bash
if [ ! $# -eq 1 ];then
	echo "need only one param!"
	exit 1
fi

cat /etc/passwd | awk -F: '{print $1}' | grep -w $1

if [ $? -eq 1 ];then

su - << huawei  
userdel -rf $1  1>> ok.log 2>> fail.log
fi
-------------------------------------------------------------------------------------------
#!/bin/bash
read -p "enter your name?" name

read -p "enter your age?" age

echo "your name is ${name}, and your age is ${age}"


#!/bin/bash
sh re.sh << OVER
xuxu
35
OVER
-------------------------------------------------------------------------------------------
#!/bin/bash
while read k v
do
	#必须加上``
 eval  `echo "${k}=${v}"`
done < data.txt
echo 'name = '$name
-------------------------------------------------------------------------------------------
#!/bin/bash

cat /etc/hosts | grep -v '^#' | grep -v '^$' | while read line
do
	addr=`cat $line | awk '{print $1}'`
	ping -s -C1 $addr
done

-------------------------------------------------------------------------------------------
#!/bin/bash
while [ $# -gt 0 ]
do
	echo '$#='$#
	echo $1
	shift
done
-------------------------------------------------------------------------------------------
who -u:显示当前的所有用户，及这些用户的进程号
who -r:显示系统的运行级别
-------------------------------------------------------------------------------------------
sed '1a \
line1\
line2\
line3' data.txt
-------------------------------------------------------------------------------------------
sort -t: -k2 dd.txt

ls -A:显示所有文件，不包括.和..
-------------------------------------------------------------------------------------------
#!/bin/bash
if :#空命令，永远为真
then
   echo "ok"
else : #空命令，永远为真
fi
```