即使重定向到/ dev / null或txt文件后,我还是将这些消息作为输出的一部分来获得,无论如何避免这些消息?
./a.txt: line 44: opatch: command not found
./a.txt: line 44: /dev/null: Permission denied
grep: /ContentsXML/inventory.xml: No such file or directory
重定向不起作用。 这是代码
inventory_dir=`opatch lsinventory |grep -i 'Central Inventory' | cut -d ":" -f2` 2>&1 /dev/null
答案 0 :(得分:1)
命令重定向不适用于该命令中的替换。
您可以将它们全部包装在{ ..; }
中并重定向:
{
inventory_dir=`opatch lsinventory |grep -i 'Central Inventory' | cut -d ":" -f2`
} 2> /dev/null
答案 1 :(得分:0)
使用此stock_dir = opatch lsinventory |grep -i 'Central Inventory' | cut -d ":" -f2
> output.txt或>>