我有一个罕见的问题。
当我通过控制台执行文件时,它运行良好,但是当我通过 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
你的第一行不是 shebang 行。你想要#!/usr/bin/env bash
.如果没有感叹号,这一行只是另一个注释,脚本将在 cron 使用的 shell 中执行(通常/bin/sh
)。 <(my_command)
是一种害羞,因此语法错误。