Listing time every second as a Bash script
- by Caleb
Hello all, first time here as I've finally started to learn programming. Anyway, I'm just trying to print the time in nanoseconds every second here, and I have this:
#!/usr/bin/env bash
while true;
do
date=(date +%N) ;
echo $date ;
sleep 1 ;
done
Now, that simply yields a string of date's, which isn't what I want. My learning has been rather messy, so I hope you'll excuse me for this if it's really simple. Also, I did manage to fine this, that worked on the prompt:
while true ; do date +%N ; sleep 1 ; done
But that obviously doesn't work as a script.