grep输出放入while循环 [英] grep output placed into a while loop
本文介绍了grep输出放入while循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前已将我的grep输出配置为将所有内容放置在文件中,我正在尝试设置一些不需要创建文件的地方.
I currently have my grep output configured to place everything in a file, i'm trying to set something up where a file will not need to be created.
func_database () {
egrep "^[0-9]" file.txt | egrep "/ON /" | sed s/-[^@]*$// > /users/home/myhome/log/test.txt
}
func_database
while read -r line ; do
echo "Database $line Area a:"
python amgr.py status $line a
echo ""
echo "Database $line Area b:"
python amgr.py status $line b
echo ""
echo "Database $line Area c:"
python amgr.py status $line c
echo ""
done </users/home/myhome/log/test.txt
以上是我当前的设置,无论如何,我可以进行一些设置,以便在运行while; do函数之前,无需将该信息发送到test.txt文件. python脚本只会在屏幕上输出状态. test.txt文件包含以数字分隔的数字列表,例如
Above is my current setup, is there anyway i can set something up where i will not need to send this information to the test.txt file prior to running it in the while;do function. The python script will just output the status on screen. The test.txt file contains a list of numbers seperated by line for example
0
15
32
78
95
推荐答案
将您的输出直接放入while
:
func_database () {
egrep "^[0-9]" file.txt | egrep "/ON /" | sed s/-[^@]*$//
}
func_database |
while read -r line
do
echo "Database $line Area a:"
python amgr.py status $line a
echo ""
echo "Database $line Area b:"
python amgr.py status $line b
echo ""
echo "Database $line Area c:"
python amgr.py status $line c
echo ""
done
这篇关于grep输出放入while循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文