Wednesday, November 1, 2017

Bash for loop examples


Buy Moto series phones: Moto E, Moto G, Moto X or Other phones
Buy eBooks from Flipkart
-----------------------------------------------

For loop example in bash script:
To get yarn log files for multiple spark jobs, we can use this command.
for i in `cat appid.txt`; do echo $i; yarn logs -applicationId $i > sparkjob_01sep_logs/$i.log; echo "——"; done




For loop with sequence and ssh into multiple servers:
To login into multiple servers and run a command, we can use below command.

for i in `seq 101 125`;do ssh -q machinename$i "hostname;ls -ltr";done



No comments:

Post a Comment

Latest Posts