Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

226
Vistas
bash loop with GNU less that refreshes every 2 minutes

I have a linux machine with a data folder and a script that produces a report xlsx spreadsheet file on the ever changing content of the folder where it is being run. I use a xlsx2tsv script to convert it to tsv text which takes less than one second. The script takes about 1 minute to produce the spreadsheet file and I want to have a terminal screen showing the results of the table in a GNU less buffer, where I can move around with the cursors, and search for content with /search, etc. of the most up-to-date version of the content.

At the moment I have a bash while true; do loop which first calculates the content of the script, then transforms it to tsv and pipes it to GNU less. Then in another terminal screen I have a while true; do loop that kills the less command every 2 minutes. But this leaves me with 1 minute of inactivity, where I am waiting for the spreadsheet to be updated before being able to navigate the content with less.

I would like to optimise this setup so that a new spreadsheet is produced in the background not when I kill the less command, but starting 1 minute before, so that the updated less command always gives me a working copy that I can navigate. Ideally without having to create a third terminal window for it.

Any ideas? Maybe GNU parallel?

Current setup:

# screen in the data folder with less command
while true; do $HOME/script -dir $PWD && xlsx2tsv $(ls $PWD/*.xlsx) 1 | column -t | less -S -N; sleep 0.5; done
# screen 2 with the less killing
while true; do pkill less; sleep 120; done
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

My less man page says this about the "R" command

R Repaint the screen, discarding any buffered input. Useful if the file is changing while it is being viewed.

So, just hit R to refresh.

over 4 years ago · Santiago Trujillo Denunciar

0

while true; do
  (sleep 0.5
   $HOME/script -dir $PWD &&
   xlsx2tsv $(ls $PWD/*.xlsx) 1 |
   column -t > new;
   mv new old;
   killall less
  ) &
  less -S -N old
done
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda