读取文件行

来源:互联网 发布:淘宝客佣金计算 编辑:程序博客网 时间:2024/06/16 17:41

1.echofile.sh

 

#! /bin/bash
File=passwd
{
   read line1
   read line2
} < $File

echo "First line in $File is:"
echo "$line1"
echo
echo "Second line in $File is:"
echo "$line2"

exit 0

 

2.

 

#! /bin/bash
# rpm file check

SUCCESS=0
E_NOARGS=65

if [ -z "$1" ]; then
  echo "Usage: `basename $0` rpm-file"
  exit $E_NOARGS
fi

{
  echo
  echo "Archive Description:"
  rpm-qpi $1
  echo
  echo "Archive Listing:"
  rpm-qpl $1
  echo
  rpm -i --test $1
  if [ "$?" -eq $SUCCESS ]; then
    echo "$1 can be installed"
  else
    echo "$1 cannot be installed."
  fi

  echo
} > "$1.test"

echo "Results of rpm test in file $1.test"
exit 0

原创粉丝点击