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 ...
随机推荐
- 数据库 Mysql内容补充二
多表查询 mysql支持的是SQL99标准的连接查询,并不支持oracle公司的外连接查询, 但是支持oracle等值查询,不等值查询,自连接查询,子查询(只要不是外连接(+)都支持) oracle也 ...
- 【C++】线程_beginthreadex参数说明
unsigned long _beginthreadex( void * _Security, //第1个参数:安全属性,NULL为默认安全属性 unsigned _StackSize, //第2个参 ...
- 模式识别之线性判别---naive bayes朴素贝叶斯代码实现
http://blog.csdn.net/xceman1997/article/details/7955349 http://www.cnblogs.com/yuyang-DataAnalysis/a ...
- linux源代码编译安装OpenCV
为了尽可能保证OpenCV的特性,使用OpenCV源代码编译安装在linux上.先从安装其依赖项開始,以ubuntu 14.04.X为例解说在Linux上源代码编译安装OpenCV,其它linux版本 ...
- markdown 转 pdf 方法
(1)Mou: (macosx 系统下的markdown编辑器,转pdf完美,推荐) http://25.io/mou/ (2)Chrome 打印 (打印得很好看,缺点是转好的pdf上的文字有时候不能 ...
- CentOS查看操作系统信息(重要)
1.查看物理CPU的个数 [root@MysqlCluster01 ~]# cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc ...
- php date strtotime的用法
1.上个月第一天及最后一天. echo date('Y-m-01', strtotime('-1 month')); echo strtotime(date('Y-m-01 0:00:00', str ...
- php中ignore_user_abort函数的用法(定时)
PHP中的ignore_user_abort函数是当用户关掉终端后脚本不停止仍然在执行,可以用它来实现计划任务与持续进程,下面会通过实例讨论ignore_user_abort()函数的作用与用法. i ...
- while循环中,break,continue,return的差别
break 结束循环,跳出循环体: continue 结束本次循环.进行下次循环: return 跳出循环体所在的方法,相当于跳出循环体.
- VS 清除编译产生的临时文件、文件夹
VS编译过程中会产生一些临时文件,通过以下脚本可清除 @echo off for /r %%i in (*.sdf,*.ncb,*.suo,*.exp,*.user,*.aps,*.idb,*.dep ...