সঙ্গে ddআপনি নির্ভরযোগ্যভাবে একটি ফাইল থেকে একটি একক বাইট পড়তে পারেন। সঙ্গে sttyআপনি একটি সেট করতে পারেন minএকটি টার্মিনাল পড়ে এবং যোগ্যতা বাইটের সংখ্যা timeএক সেকেন্ডের দশমাংশ আউট। এই দুটি একত্রিত করুন এবং আপনি sleepসম্পূর্ণরূপে ছাড়াই করতে পারেন , আমি মনে করি এবং টার্মিনালের পড়ার সময়সীমা আপনার জন্য কাজটি করতে দিন:
s=$(stty -g </dev/tty)
(while stty raw -echo isig time 20 min 0;test -z "$(
dd bs=1 count=1 2>/dev/null; stty "$s")" || (exec sh)
do echo "$SECONDS:" do your stuff here maybe
echo no sleep necessary, I think
[ "$((i+=1))" -gt 10 ] && exit
done
) </dev/tty
এটি একটি সামান্য উদাহরণ whileলুপ যা আমি আপনাকে চেষ্টা করে দেখার জন্য উপহাস করেছি। প্রতি দুই সেকেন্ড ddপরে এর চেষ্টা করার চেষ্টা করে stdin- এর থেকে পুনঃনির্দেশিত /dev/tty- এবং whileলুপ লুপগুলি। এটি বা সময়সীমা dd ছাড়ায় না কারণ আপনি একটি কী টিপেন - এমন ক্ষেত্রে একটি ইন্টারেক্টিভ শেলটি চাওয়া হয়।
এখানে একটি পরীক্ষা চালানো হয়েছে - প্রতিটি লাইনের শিরোনামে মুদ্রিত সংখ্যাগুলি শেল ভেরিয়েবলের মান $SECONDS:
273315: do your stuff here maybe
no sleep necessary, I think
273317: do your stuff here maybe
no sleep necessary, I think
273319: do your stuff here maybe
no sleep necessary, I think
273321: do your stuff here maybe
no sleep necessary, I think
sh-4.3$ : if you press a key you get an interactive shell
sh-4.3$ : this example loop quits after ten iterations
sh-4.3$ : or if this shell exits with a non-zero exit status
sh-4.3$ : and speaking of which, to do so you just...
sh-4.3$ exit
exit
273385: do your stuff here maybe
no sleep necessary, I think
273387: do your stuff here maybe
no sleep necessary, I think
273389: do your stuff here maybe
no sleep necessary, I think
273391: do your stuff here maybe
no sleep necessary, I think
273393: do your stuff here maybe
no sleep necessary, I think
273395: do your stuff here maybe
no sleep necessary, I think
273397: do your stuff here maybe
no sleep necessary, I think
sleep 10; notify-send helloএবং থামাতে CTRL + Z টিপুন,notify-send helloমৃত্যুদণ্ড কার্যকর করুন। যদি দ্বিতীয় কমান্ড কার্যকর হয় তবে প্রথম প্রক্রিয়াটি কীভাবে বন্ধ হবে? তারপরে যদি টাইপfgকরতাম না তবে কিছুই ঘটতে পারে, যা স্পষ্টতই, যেহেতু দ্বিতীয় কমান্ড ইতিমধ্যে কার্যকর করা হয়েছে