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 ...
随机推荐
- 轻量级ORM框架Dapper应用一:Dapper安装
一.Dapper简介 Dapper是一款轻量级ORM框架,为解决网站访问流量极高而产生的性能问题而构造,主要通过执行TSQL表达式而实现数据库的CQRS. 如果你在项目中遇到性能访问问题,选择Dapp ...
- SQL Server查询某个字段存在哪些表中
一.查询SQL Server中所有的表 SQL语句:SELECT * FROM sys.tables name列表示所有的表名. 二.查询SQL Server中所有的列 SQL语句:SELECT * ...
- solr学习2
1:solr中的时间问题 solr中显示的时间默认会比我们本机时间少八个小时,因为时区不一样. 在solr的web页面查看会发现时间少八个小时. 但是使用java代码操作的时候是整成的的,所以在这只需 ...
- SpringMVC--拦截器的使用
SpringMVC的请求如下面这种图所示: 可以看出所有的请求都要通过Dispatherservlet来接收,然后通过Handlermapping来决定使用哪个控制器,再根据ViewResolver ...
- IE屏蔽鼠标右键、禁止复制粘贴等功能
<body oncontextmenu="return false" onselectstart="return false" ondragstart=& ...
- spring FactoryBean配置Bean
概要: 实例代码具体解释: 文件夹结构 Car.java package com.coslay.beans.factorybean; public class Car { private String ...
- c++ list 合并list
1.参考 http://www.cplusplus.com/reference/list/list/ 2.合并 主要有两个函数:splice()和merge()splice()有三种调用形式:第一种: ...
- POSIX是什么?
1.什么是POSIX? POSIX是可移植操作系统接口(Portable Operating System Interface for UNIX)的缩写,是IEEE为了在各种UNIX操作系统上运行软件 ...
- JavaScript匿名函数和回调函数
匿名函数的自调函数格式: (function(){ //代码 })(); <script type="text/javascript"> (function(){ al ...
- STL 源代码剖析 算法 stl_algo.h -- search_n
本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie search_n ------------------------------------- ...