일부 파일이있는 tmp 디렉토리가 있습니다. 이 파일 이름을 구문 분석 한 다음 각 파일의 내용을 구문 분석해야합니다.
!/bin/bash
TMPDIR=/home/david/tmp
ip_targets(){
while IFS= read -r file_name; do
echo "This is: $file_name"
while IFS= read -r ip;do
echo "This is IP: $ip"
done < <(cat "$file_name") ## Is this wrong ?
done < <(find "$TMPDIR" -regex '.*.vms$')
}
ip_targets
이것을 어떻게 달성 할 수 있습니까? 위의 내용은 $ file_name이 에코되도록 허용하지만 그 내용은 아닙니다.
이 시도:
!/bin/bash
TMPDIR=/home/david/tmp
ip_targets(){
while IFS= read -r file_name; do
echo "This is: $file_name"
grep -woE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" $file_name
done < <(find "$TMPDIR" -regex '.*.vms$')
}
ip_targets
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다