Unix(和SO)新手在这里试图弯曲我的新生命令行剁.
我正在尝试使用grep和sed扫描当前目录中的一堆文件,并将所有出现的字符串"192.168.1.1"替换为字符串"192.168.1.0",同时单独保留.git文件夹.
我尝试了以下方法:
grep -lr --exclude-dir=".git" "192.168.1.1" . | xargs sed -i 's/192.168.1.1/192.168.1.0/g'
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
sed: 1: "./contact.html": invalid command code .
Run Code Online (Sandbox Code Playgroud)
如果有人能帮我弄清楚我的命令有什么问题,我真的很感激.
我也有兴趣了解一种更有效的方法来完成这项任务,特别是如果命令更简洁,更容易记住,只要它不涉及在perl/bash/etc中编写脚本,但我'我目前正试图深入研究sed和grep,我仍然有兴趣了解为什么这个命令不能正常工作,即使提供了一个工作替代方案.
aiohttp很棒,但是在本地和生产环境中使用Gunicorn.
我发现的大多数用于设置日志记录的示例和文档都用于在本机服务器模式下运行,您可以在其中使用 make_handler()
正如文档中所建议的,我将其Gunicorn用作 Web 服务器进行部署,因此我没有make_handler明确调用。
我没有看到 aiohttp.access 日志,也没有看到 aiohttp.server 日志,也没有看到 aiopg 日志,所有这些都应该默认设置
这是我在根级别得到的app.py:
import logging
import aiopg
from aiohttp import web
async def some_handler(request):
id = request.match_info["id"]
# perform some SA query
return web.json_response({"foo": id})
async def close_postgres(app):
app['postgres'].close()
await app['postgres'].wait_closed
async def init(loop, logger, config):
app = web.Application(
loop=loop,
logger=logger
)
app['postgres'] = await aiopg.sa.create_engine(loop=loop, echo=True) # other args ommitted
app.on_cleanup.append(close_postgres)
app.router.add_route('GET', '/', some_handler, 'name')
return app
def run(): …Run Code Online (Sandbox Code Playgroud)