bash - Passing a variable to sed inside for loop -
i have loop written in script so:
for((i=0;i<${#hours[@]})); dates=("$(last | egrep -v "reboot|wtmp|^$" | sort | tr -s " " | sed "$i q;d" | cut -f5-7 -d' ')") done
if execute command assigned dates
in terminal, replacing $i
(inside sed command) number (0,1,2...), returns me want, is, instance nov 15 23:15
.
however, when inside for
loop, seem have problem sed command not incrementing $i
. doing wrong?
your problem never change i
. should update in third part of for
statement:
for((i=0;i<${#hours[@]};++i)); # ^^^ here
Comments
Post a Comment