• Linix登录报"/etc/profile: line 11: syntax error near unexpected token `$'{ ''"


    同事反馈他在一测试服务器(CentOS Linux release 7.2.1511)上修改了/etc/profile文件后,使用source命令不能生效,让我帮忙看看,结果使用SecureCRT一登录就发现下面错误信息:

    Last login: Fri Nov 4 00:42:45 2016 from 10.20.34.14
     
    -bash: $'
    ': command not found
     
    -bash: $'
    ': command not found
     
    -bash: $'
    ': command not found
     
    -bash: /etc/profile: line 11: syntax error near unexpected token `$'{
    ''
     
    'bash: /etc/profile: line 11: `pathmunge () {

    clip_image001

     

    错误提示信息已经反馈/etc/profile里面有一些异常,初步检查/et/profile文件后,没有发现异常,很是奇怪,后面我使用cat -v /etc/profile检查,发现里面大量的Windows下的换行符。如下截图所示

     

    clip_image002

     

    咨询了一下他是怎么修改,他反馈是将该文件拷贝出来,然后用文本编辑器修改,然后覆盖原文件。到这里已经知道具体原因了,使用dos2unix profile将profile文件从Windows格式文件转换为Unix、Linux格式,然后在执行source profile使之生效,问题解决。

  • 相关阅读:
    Codeforces 1149 B
    Tenka1 Programmer Contest 2019 D
    BZOJ 1001 [BeiJing2006]狼抓兔子
    Codeforces 741 D
    HDU 5306 Gorgeous Sequence
    HDU 6521 Party
    Codeforces 912A/B
    Educational Codeforces Round 35 B/C/D
    Codeforces 902D/901B
    Codeforces 902B
  • 原文地址:https://www.cnblogs.com/kerrycode/p/6029043.html
Copyright © 2020-2023  润新知