我有一个罕见的问题。
当我通过控制台执行文件时,它运行良好,但当我通过crontab执行它(同一文件)时,我在代码的以下部分收到错误
join -j 1 -t ',' <(sort $dir/Xem3.csv) <(sort $dir/coordenades.csv)|awk -F "," '{print $15","$16","$17"," $3"," $4","$18"," $5"," $6","$7","$8"," $9","$10","$11","$12","$13}' > $dir/Xem4.csv
crontab日志中的错误是
/home/enric/proves/web.sh: line 95: syntax error near unexpected token `('
/home/enric/proves/web.sh: line 95: `join -j 1 -t ',' <(sort $dir/Xem3.csv) <(sort $dir/coordenades.csv)|awk -F "," '{print $15","$16","$17"," $3"," $4","$18"," $5"," $6","$7","$8"," $9","$10","$11","$12","$13}' > $dir/Xem4.csv'
任何想法?
我的脚本是
#/bin/bash
dir=/home/enric/proves
join -j 1 -t ',' <(sort $dir/Xem3.csv) <(sort $dir/coordenades.csv)|awk -F "," '{print $15","$16","$17"," $3"," $4","$18"," $5"," $6","$7","$8"," $9","$10","$11","$12","$13}' > $dir/Xem4.csv
tr -d '\r' < $dir/Xem4.csv > $dir/out.csv
答案 0 :(得分:2)
你的第一行不是一个shebang线。你想要#!/usr/bin/env bash
。没有感叹号,该行只是另一个注释,脚本将在cron使用的shell中执行(通常为/bin/sh
)。 <(my_command)
is a bashism,因此语法错误。