मुझे यह काम करने के लिए "मानक" लिनक्स टूल नहीं मिला, लेकिन मैं आमतौर पर स्थापना से लेकर इंस्टॉलेशन तक अपनी डॉट फाइलें (.bashrc, .vimrc आदि) संरक्षित करता हूं, इसलिए यदि आप इसे देखते हैं, तो निम्न "मानक" है। नई स्थापनाओं में अपनी डॉट फ़ाइलों को संरक्षित करने का परिप्रेक्ष्य:
अपने .bashrc या .bash_aliases के अंत में, निम्नलिखित परिभाषा डालें:
repeat() {
n=$1 #gets the number of times the succeeding command needs to be executed
shift #now $@ has the command that needs to be executed
while [ $(( n -= 1 )) -ge 0 ] #loop n times;
do
"$@" #execute the command; you can also add error handling here or parallelize the commands
done
}
फ़ाइल को सहेजें और या तो खोल को फिर से खोलें या निष्पादित करें source /path/to/.bashrcया source /path/to/.bash_aliases, जो भी आप मौजूदा शेल में संशोधित करना चाहें।
बस! आपको निम्नलिखित तरीके से इसका उपयोग करने में सक्षम होना चाहिए:
repeat 100 echo hello
repeat 84 ~/scripts/potato.sh
आदि।