简体   繁体   English

循环bash shell脚本

[英]Loop bash shell script

I have a bash shell script that outputs an iCal event using iCal Buddy which displays 2 events like: 我有一个bash shell脚本,该脚本使用iCal Buddy输出一个iCal事件,该事件显示2个事件,例如:

  • Event1 Title 事件1标题
  • Event1 Date 活动1日期
  • Event2 Title Event2标题
  • Event2 Date 事件2日期

I would like to have the script output like: 我想要脚本输出如下:

  • Event Title 活动标题
  • Event Date 活动日期

(wait 10 seconds) clear the Event Title, Event Date, then output the next Event Title, Event Date (wait 10 seconds) then loop back to the first Event and continue looping. (等待10秒)清除事件标题,事件日期,然后输出下一个事件标题,事件日期(等待10秒),然后循环回到第一个事件并继续循环。 I've tried using the command followed by sleep 10, and repeating the command with | 我试过使用命令sleep 10,然后使用|重复该命令。 head -n 4 | 头-n 4 | tail -n 2, although then it only outputs the second Event. tail -n 2,尽管随后它仅输出第二个Event。

How can I do this? 我怎样才能做到这一点? (my shell script is below) Thanks! (我的shell脚本在下面)谢谢!

/usr/local/bin/icalBuddy -npn -nc -n -iep "title,datetime" -b "★ "  -ps "| ★\n|" -po "title,datetime" -nrd -df "%a, %b %e" eventsToday+2 | cut -c 1-33

2 2

Unless I misunderstand you, this should do what you want: 除非我误解了您,否则这应该做您想要的:

while true
do
    clear
    command | pipeline | head -n 2
    sleep 10
    clear
    command | pipeline | head -n 4 | tail -n 2
    sleep 10
done

Where "command | pipeline" represents the icalBuddy and cut in your question. 其中“命令|管道”代表icalBuddycut您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM