与GNU bash的循环小于刷新每2分钟 [英] bash loop with GNU less that refreshes every 2 minutes

查看:166
本文介绍了与GNU bash的循环小于刷新每2分钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台Linux机器与数据文件夹,并产生于它正在运行的文件夹的不断变化的内容报告XLSX US preadsheet文件的脚本。我用一个脚本xlsx2tsv将其转换为文本TSV这需要不到一秒钟。该脚本需要大约1分钟,在S preadsheet文件,我想有一个显示在GNU较少的缓冲区,在那里我可以用光标移动,并与<搜索内容表的结果的终端屏幕code> /搜索,最先进的最新版本的内容等。

目前,我有一个bash 而真实的;做环路首先计算脚本的内容,那么会将其转换成TSV,它管道 GNU少。然后在另一个终端屏幕我有一个而真实的;做循环,杀死命令每2分钟。但是,这给我留下了不活动1分钟,在那里我等待了S preadsheet能够导航与的含量较少之前更新。

我想优化这个设置,使新的S preadsheet是不是我杀的少命令的背景产生的,但在此之前开始1分钟,使更新后的命令总是给我一份工作,我可以导航。理想的情况下,无需为它创建一个第三终端窗口。

任何想法?也许GNU水货?

当前设置:

 #屏幕数据文件夹用更少的命令
而真实的;做$ HOME /脚本-dir $ PWD和放大器;&安培; xlsx2tsv $(LS $ PWD / * XLSX)1 |列-t |少-S -N;睡0.5; DONE
#2的屏幕与少杀
而真实的;做pkill的少;睡120; DONE


解决方案

我少手册页说,这对R命令


  

研究重画屏幕,丢弃任何缓冲输入。有用的,如果该文件,而它改变
             正在观看


所以,只要按<大骨节病>研究刷新。

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

解决方案

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.

这篇关于与GNU bash的循环小于刷新每2分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆