Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 更新股票grep?_Shell - Fatal编程技术网

Shell 更新股票grep?

Shell 更新股票grep?,shell,Shell,stock.txt 产品:A股票:1 产品:B股票:2 产品:C存货:3 我想用任何数字来更改b项的库存数量?我应该使用grep命令吗?是否要使用“sed” 像这样的 sed -e 's/B Stock: 2/B Stock 10/' stock.txt 这将把库存2替换为库存10 Product: A Stock: 1 Product: B Stock 10 Product: C Stock: 3 Grep无法为您修改该文件。谢谢,我会尝试的。如何删除同一行?您可以使用sed、Grep

stock.txt

产品:A股票:1

产品:B股票:2

产品:C存货:3

我想用任何数字来更改b项的库存数量?我应该使用grep命令吗?

是否要使用“sed”

像这样的

sed -e 's/B Stock: 2/B Stock 10/' stock.txt
这将把库存2替换为库存10

Product: A Stock: 1

Product: B Stock 10

Product: C Stock: 3

Grep无法为您修改该文件。谢谢,我会尝试的。如何删除同一行?您可以使用sed、
Grep-v
、awk。。。