代码之家  ›  专栏  ›  技术社区  ›  adam smith

正则表达式gawk匹配

  •  0
  • adam smith  · 技术社区  · 10 年前

    ALLOWED_HOSTS = [] 行。我正在使用 gawk '$1 ~ /ALLOWED_HOSTS =.+$/{ print $0 }' file_name .我没有找到任何匹配项。这很令人费解。我试过用 /^ALLOWED_HOSTS =.+$/ ,但没有成功。请查看文本末尾附近的内容,以查看我试图匹配的行。

    Django settings for superlists project.
    
    For more information on this file, see
    https://docs.djangoproject.com/en/1.7/topics/settings/
    
    For the full list of settings and their values, see
    https://docs.djangoproject.com/en/1.7/ref/settings/
    """
    
    # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
    import os
    BASE_DIR = os.path.dirname(os.path.dirname(__file__))
    
    
    # Quick-start development settings - unsuitable for production
    # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
    
    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = '4(8f0buww1_&0jqmo-zg89$!epi=zd0)z3v^d+qp&z63fg*bin'
    
    # SECURITY WARNING: don't run with debug turned on in production!
    DEBUG = True
    
    TEMPLATE_DEBUG = True
    
    ALLOWED_HOSTS = []
    
    
    # Application definition
    
    1 回复  |  直到 10 年前
        1
  •  1
  •   tripleee    10 年前

    $1 仅包含 ALLOWED_HOSTS $0 --如果您没有提供要比较的特定值,那么这无论如何都是隐含的,因此您的整个脚本相当于

    gawk '/ALLOWED_HOSTS/' file_name