[英]Bash getting everything to the same line?
I have been working on this all morning with no luck. 我整个上午一直在努力,没有运气。 I need the results to be all on one line comma delimited. 我需要将结果全部放在逗号分隔的一行上。 Some portions were working fine but once I added the read it feel apart! 有些部分工作正常但是一旦我添加了阅读它感觉分开!
INPUT=steamIPs.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read router contact address
do
myvar="$ip
$router
$contact
$address"
echo "$myvar" | paste -s -d','
OUTPUT=`snmpget $ip -c public -v 1 sysuptim`
echo ${OUTPUT#*:} | tr -d ' '
done < $INPUT
IFS=$OLDIFS
You're working too hard: 你工作太辛苦了:
if [[ ! -f "$INPUT" ]]; then
echo "$INPUT file not found"
exit 99
fi
while IFS=, read -r router contact address; do
myvar="$ip,$router,$contact,$address"
echo "$myvar"
done < "$INPUT"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.