0
csv 파일에 여러 변수를 인쇄 할 수 있기를 원합니다. 변수는 파일 유형에 따라 다릅니다. 또한 특정 변수를 옵션으로 지정할 수도 있습니다. 예를 들어 내가 그것은 다음과 같이 실행 할 생각이라고 : 주어진지정된 줄 수에 대해 CSV 파일로 인쇄 할 Bash 스크립트
./pickafile.sh format1 date time(optional) duration(optional)
예 :
./pickafile.sh watchtv 21112014 150000 10
이 할 것
#!/bin/sh
var1=date (format DDMMYYYY)
time=time (format HHMMSS)
var2=duration (in seconds)
var3='Watchtv'
cheese='Cheddar'
num=20 #number times to print
case $file_type in
watch_tv)
cheese='stilton'
for i in 1..$num
do
## print to a csv file each row adding the
echo $var1,$time+$var2,$var2,$var3,$cheese > $watch_tv.csv
done
;;
watch_ppl)
echo 'watch ppl??'
;;
watch_animals)
echo $'wahtc animals?'
exit 1
;;
*)
echo "Unknown file- sure it isn't toxic?"
esac
done
exit
다음을 이렇게 파일의 출력이 60 초를 추가 보일 것이다 각 시간대 20 회
21112014,150000,10,Watchtv,stilton
21112014,150010,10,Watchtv,stilton
21112014,150020,10,Watchtv,stilton
21112014,150030,10,Watchtv,stilton
21112014,150040,10,Watchtv,stilton
21112014,150050,10,Watchtv,stilton
21112014,150100,10,Watchtv,stilton
etc
감사합니다. 당신 정말 대단하네요 :-) – hobbyscripter