Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!