Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

227
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda