Skip to content

Instantly share code, notes, and snippets.

@kunpengku
Created June 16, 2014 07:23
Show Gist options
  • Save kunpengku/4616e52ba7e7d1e37d54 to your computer and use it in GitHub Desktop.
Save kunpengku/4616e52ba7e7d1e37d54 to your computer and use it in GitHub Desktop.
将一段代码块的输出 重定向到一个文件中
#!/bin/bash
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 cat not be installed"
fi
} > "$1.test"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment