0

I have a file, "thefiles.txt", just the output of an "ls -l" command. I am interested in processing the first several timestamps. I can get them from

> head thefiles.txt | cut -d ' ' -f 9
16:19
16:20
16:21
16:22
16:24
16:25
16:26
16:27
16:28
16:29

Now, what I really want to do is put them into a bash array that I'll call tms:

> declare -a tms
> head thefiles.txt | cut -d ' ' -f 9 | while read next_line
do
echo $next_line
tms+=($next_line)
done

The output from the echo command looks promising:

16:19
16:20
16:21
16:22
16:24
16:25
16:26
16:27
16:28
16:29

But none of the values ever get into tms:

> echo ${tms[@]}
(blank line)

I have tried a few variations such as

tms+=(next_line)
tms+=(${next_line[@]})

Anyone know how to make this work? If you've got a completely different better approach, I wouldn't mind hearing that either. (Still, for my own edification, I would like to figure this problem out.)

bob.sacamento
  • 6,283
  • 10
  • 56
  • 115

0 Answers0