shell出现syntax error near unexpected token `<' 解决方法
最新在看一个shell资料时,按照教材,却出现如下错误,不能运行
如下,简单的脚本:
#!/bin/bash
cat |while read line
do
echo $line
done < <(data.txt|awk '{print $0}')
运行时,却出现如下错误
[root@localhost shellcookbook]# sh while_test.sh
while_test.sh: line : syntax error near unexpected token `<'
while_test.sh: line : `done < <(data.txt|awk '{print $0}')'
然后在单行运行时,却没有错误
[root@localhost shellcookbook]# while read line;do echo $line;done < <(cat data.txt|awk '{print $1}')
在网上查看后,确认无脚步错误,无dos文件错误。还是没有好的解决方法。通过多方求证。原来是bash 3.0后,shell中加入了新的符号"<<<" 可以获取子任务
现将脚本更改如下,成功运行:
#!/bin/bash
cat |while read line
do
echo $line
done <<< `cat data.txt|awk '{print $0}'`
成功运行
[root@localhost shellcookbook]# sh while_test.sh
shell出现syntax error near unexpected token `<' 解决方法的更多相关文章
- 解决shell脚本“syntax error near unexpected token `fi'”的问题。
执行shell脚本的时候,提示如下错误: 查询资料后发现: 执行: vi finddir.sh 然后,输入 :set ff 结果是: 解决方案就是,修改为unix: :set ff=unix 执行保存 ...
- 写shell,运行出错:syntax error near unexpected token `$’do\r”
cygwin下面写shell,运行出错:syntax error near unexpected token `$’do\r” 写shell,运行出错:syntax error near unexpe ...
- shell编程报错:“syntax error near unexpected token `”
今天写了个shell脚本,在自己机器上运行正常,给同事,运行报错syntax error near unexpected token `,左看右看shell脚本没有问题,没有办法google搜索,发现 ...
- Shell脚本报错--syntax error near unexpected token for((i=0;i<$length;i++))
现象: shell脚本使用Nodepad++进行本地编辑,在编辑后上传到linux机器进行执行时提示“syntax error near unexpected token for((i=0;i< ...
- syntax error near unexpected token `then'问题的解决
#!/bin/bash #if program test echo 'a:' read a if [ "$a" = "English" ];then ...
- 执行shell脚本提示“syntax error near unexpected token for((i=0;i<$length;i++))”
sh脚本例如以下: #!/usr/bin/env bash county="3 4 5 6 7 8 9 10 11 12 16 29 39 44 53 62 72 84 97 115 128 ...
- syntax error near unexpected token `do(写的shell脚本出现格式问题)--->1.问题2.展示信息3.解决方案
1问题:Linux和windows下的回车换行符不兼容的问题 [root@node-01 script]# sh start_zk.sh art_zk.sh: line 3: syntax error ...
- 解决执行脚本报syntax error: unexpected end of file或syntax error near unexpected token `fi'错误的问题
参考:https://blog.csdn.net/u012453843/article/details/69803244 解决执行脚本报syntax error: unexpected end of ...
- syntax error near unexpected token `then'问题的解决
http://blog.csdn.net/gongmin856/article/details/7690917 #!/bin/bash #if program test echo 'a:' read ...
随机推荐
- YARN : Architecture of Next Generation Apache Hadoop MapReduceFramework
转自:http://blog.csdn.net/colorant/article/details/9146201 == 目标问题 == 下一代的Hadoop框架,支持10,000+节点规模的Hadoo ...
- 关于在Andoird集成开发软件中添加外部jar包的方法
步骤必须是下面的两步,少一步都不行. 第一步是存放于项目中,第二步是导入和应用于项目中. 1.右键项目-Build Path-Configure Build Path-在Libraries目录下-点右 ...
- 用C语言显示汉字的演示程序
汉字是方块字,宽高相等的汉字库在嵌入式领域有着广泛的应用,且其解析也相对来说是比较简单的.汉字在汉字库中的索引一般会遵循GB2312/GBK编码规则,GB2312/GBK规定汉字编码由2个字节组成,其 ...
- ffmpeg笔记——UDP组播接收总结
ffmpeg在avformat_open_input里面已经实现了UDP的协议,所以只需要设置好参数,将url传递进去就可以了. 和打开文件的方式基本一样: 01 AVCodecContext *pV ...
- linux -- ubuntu桌面版安装xampp
首先,请从www.xampp.org下载最新版XAMPP. 安装 如果是xampp压缩文件 将xampp压缩文件复制到/opt下并解压.如果你计算机没有/opt目录,用 “sudo mkdir/opt ...
- HTML5的表单所有type类型
1.button:定义可点击的按钮(通常与 JavaScript 一起使用来启动脚本).<br /> <input id="" type="button ...
- mysql数据库要按当天、昨天、前七日、近三十天、季度、年查询
mysql数据库要按当天.昨天.前七日.近三十天.季度.年查询
- js中页面跳转(href)中文参数传输方式
编码: escape(参数); 解码: unescape(参数);
- java web接口controller测试控制台输出乱码
接口上配置:
- oracle 日期函数 求年的最后一天、第一天,月的最后一天
add_months(trunc(to_date('2013','yyyy') ,'yyyy'),12)-1 2013年最后一天 trunc(to_date('2013','yyyy') ,'yyy ...