awk - 无法打开管道太多打开的文件
问题描述
我收到错误,
致命:无法打开管道(打开的文件太多)
#!/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
解决方案
如果这:
"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)
推荐阅读
- c++ - 将一种类型的位重新解释为不同类型的技术
- javascript - 在laravel中通过ajax删除数据
- vim - Vim 查找和替换时间 hh:mm
- javascript - 是否可以仅在 JavaScript 中制作按钮?
- php - 自动加载一个php文件,它是jquery Ajax方法的url
- c# - 使用 EPPlus 验证 Excel(电子表格)文件
- python - PyCharm:函数参数的正则表达式字符串意图
- solidity - Solidity 错误:预期标识符,得到“LParen”
- google-chrome-extension - Chrome 扩展的可变价格许可证
- elasticsearch - 使用术语聚合执行搜索时如何返回实际值(不是小写)?