首页 > 解决方案 > 无法打开管道太多打开的文件

问题描述

我收到错误,

致命:无法打开管道(打开的文件太多)

#!/bin/bash
output="Out.txt"
trans="DEBIT_TRANSACTION_"
ls *.txt | while read line
do
 subName="$(cut -d'.' -f1 <<<"$line")"

awk -F"|" -v var="10|" 'NF!=15;  NF==15 && /^[^[:space:]]/{ "echo -n "$6" | tail -c 3" | getline terminalCountry;
    if($6 =="") terminalCountry="IND";
  $1=var$1;$6=$6"|"terminalCountry; print $0;
}' OFS="|" "$line" > /home/lradmin/script/cboiCC/cboicTxnScrip/OUTPUT/"$subName$output"

done

标签: awk

解决方案


如果这:

"echo -n "$6" | tail -c 3" | getline terminalCountry

是一件合理的事情,那么这样做的语法是:

cmd = "echo -n \047" $6 "\047 | tail -c 3"
terminalCountry = ( (cmd | getline line) > 0 ? line : "IND" )
close(cmd)

但这不是一件合理的事情。有关使用getline. _

在这种情况下,您似乎只是想从中获取最后 3 个字符$6,那就是:

terminalCountry = substr($6,length($6)-3)

推荐阅读