$sed -n 'np' file1.out Based on the input of n like 1,2,3,....... we will get desired output We can even use awk command as well $awk 'NR==n{print;exit}' file.out Based on the input of n like 1,2,3,....... we will get desired output
General While loop while command do Statement(s) to be executed if command is true done #!/bin/sh a=0 while [ $a -lt 10 ] do echo $a a=`expr $a + 1` done While loop single liner while true; do foo; sleep 2; done
Use Case: Suppose you have external customers, vendors who needs to access some information of yours AWS environment. You want to give them read only access to s3 bucket. The external users are supposed to use Rest API calls to access your s3 bucket and will require AWS Access Key and Secure Access Key. If you provide external users and later forget to retrieve or change that one, they may have permanent access to your environment. You want to give them temporary access which can lasts upto 12 hours. Solution: Create a IAM Role Attach the IAM role to an EC2 instance Share the .pem / .ppk file to access the EC2 instance External user will login to EC2 user run the command $curl http://169.254.169.254/latest/meta-data/iam/security-credentials/ iam-role Will get following AccessKeyId SecretAccessKey Token And now they can use Rest API call with above details.