Quantcast
Channel: How to run a command multiple times, using bash shell? - Server Fault
Browsing latest articles
Browse All 11 View Live

Answer by Neil for How to run a command multiple times, using bash shell?

On macOS you can use the repeat command. repeat 10 ps aux | grep someprocess

View Article



Answer by Chris Arnu for How to run a command multiple times, using bash shell?

That would be 'watch' - should be part of almost every unix system using procps You can see fs changes or otherwise interesting movement in a system. For example, watch "df -hP | grep /tmp" Just put...

View Article

Answer by masukomi for How to run a command multiple times, using bash shell?

A fish shell implementation of @eduardo-ivanec's run function above function run set number $argv[1] for i in (seq $number) eval $argv[2..-1] end end

View Article

Answer by nils-holmberg for How to run a command multiple times, using bash...

similar to previous replies, but does not require the for loop: seq 10 | xargs -I -- echo "hello" pipe output of seq to xargs with no arguments or options

View Article

Answer by Ciro Santilli 新疆改造中心法轮功六四事件 for How to run a command multiple...

POSIX way http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_04_01 x=10 while [ $x -gt 0 ]; do command x=$(($x-1)) done which could of course be made into a one liner:...

View Article


Answer by android42 for How to run a command multiple times, using bash shell?

Try this: yes ls | head -n5 | bash This requires the command to be executed in a sub-shell, a slight performance penalty. YMMV. Basically, you get the "yes" command to repeat the string "ls" N times;...

View Article

Answer by hdaz for How to run a command multiple times, using bash shell?

Just for fun pgrep ssh ;!!;!!;!!;!!;!!;!!

View Article

Answer by Lekensteyn for How to run a command multiple times, using bash shell?

ps aux | grep someprocess looks like you want to watch changes of a program for a fixed time. Eduardo gave an answer that answer your question exactly but there is an alternative: watch: watch 'ps aux...

View Article


Answer by Eduardo Ivanec for How to run a command multiple times, using bash...

I don't think a command or shell builtin for this exists, as it's a trivial subset of what the Bourne shell for loop is designed for and implementing a command like this yourself is therefore quite...

View Article


How to run a command multiple times, using bash shell?

Is there a way to run a command (e.g. ps aux|grep someprocess) for n times? Something like: run -n 10 'ps aux|grep someprocess' I want to use it interactively, please do not post scripts. Update: The...

View Article

Answer by Bill Balmant for How to run a command multiple times, using bash...

To run ps aux multiple times searching for a different known string each time:for str in {str1,str2,...}; do ps aux | grep $str | grep -v " grep "; doneThe grep -v " grep " part will remove grep itself...

View Article
Browsing latest articles
Browse All 11 View Live




Latest Images