ls форматирование внутри команды наблюдения

вот рабочий скрипт

#!/usr/bin/env bash
# download death data
wget -O Deaths.txt http://www.randomservices.org/random/data/Deaths.txt
wget -O Pumps.txt http://www.randomservices.org/random/data/Pumps.txt
# Delete the first line
sed 1d Deaths.txt > tempfile1
sed 1d Pumps.txt > tempfile2
mv tempfile1 Deaths.txt
mv tempfile2 Pumps.txt
gnuplot -persist -e "set terminal canvas;set xlabel 'x' font 'sans,15';
set ylabel 'y' font ',15';
set title 'Relationship between Deaths and Pumps' font 'sans, 20';
show title;
set label 'Most of the deaths is near the pump located in 12.6,11.7' at 16,16;
show label;
set output 'death_pump_relation.html';
plot 'Pumps.txt' with points pt 7,'Deaths.txt' with dots;"

выход умер _помпа _ratio.html

9
30.06.2021, 21:10
1 ответ

What is the reason?

Когда watchвыполняет команды, они не подключены к Терминал. Другими словами, isatty(3)возвращает 0.Вы можете использовать следующий isatty.c, чтобы проверить, подключена ли команда к терминалу когда он запущен:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(void)
{
  printf("%d\n", isatty(STDOUT_FILENO));

  return EXIT_SUCCESS;
}

Компиляция:

gcc isatty.c -o isatty

Запустите в эмуляторе терминала:

$./isatty
1

Запустите его в часах:

$ watch./isatty
Every 2.0s:./isatty                                                                                                                                                              darkstar: Wed Jun 30 20:42:51 2021

0

How can I solve this?

Используйте опцию -Cс ls в часах:

watch -d -n1 'ls -C /dev/tty*'
11
28.07.2021, 11:21

Теги

Похожие вопросы