Skip to content

Instantly share code, notes, and snippets.

@Matrix7867
Matrix7867 / delete-files-using-regex-bash.txt
Last active September 5, 2022 07:13
deleting files starting from cd-* bash for loop
for i in cd-*; do ls $i; done
#The above command to check that all the files which are starting from cd-* is listing or not.
for i in cd-*; do sudo rm $i; done
#The above command will delete all the files which start with `cd-`.
#Note: sudo command is not needed if you are performing the above command as `root` or `privileged user`
@Matrix7867
Matrix7867 / uploading_large_files_to_s3.bash
Created May 18, 2021 15:32
uploading_large_files_to_aws_s3
du -ahx . | sort -rh | head -2 | sed 1d | awk -F"./" '{ print $2 }' | xargs -I {} sudo aws s3 mv {} s3://s3example/me/mee-u/
@Matrix7867
Matrix7867 / gist:d8f91325731f467dddcc09109dd776f5
Created February 8, 2021 12:08
Adding_label_on_kube_pods_via_jenkins_after_getting_app:_and_at4_line
sed -i ":a;\\$!{N;ba};s/\\(app:\\ [a-z-]\\+\\)/\\1\\n\\ image: ${dev_tag}/4" /var/lib/jenkins/workspace/$JOB_NAME/marlo/'''+params.Environment+'''-apps/'''+params.Environment+'''-${c}.yaml
@Matrix7867
Matrix7867 / stop_stuckjenkins_pipeline
Created July 26, 2020 13:34
stopping_hung_jenkins_pipeline
Jenkins .instance.getItemByFullName("JobName")
.getBuildByNumber(JobNumber)
.finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));
@Matrix7867
Matrix7867 / copy_aritifact_to_jump_server.sh
Created July 26, 2020 10:23
copy_aritifact_to_jump_server
stage('CopyArtifactToJump') {
steps {
sshagent(credentials : ['18dddd8d7-d912-4123-bf66-303cvvvvv']) {
sh 'ssh -o StrictHostKeyChecking=no jenkins-sl@172.16.1.11 uptime'
sh 'scp /jenkins-home/workspace/dev-build/*.tar jenkins-sl@172.16.3.3:/home/jenkins-sl/workspace/volan/'
}
}
}
@Matrix7867
Matrix7867 / installing_semgrep_ubuntu18
Created July 21, 2020 07:59
Installing semgrep tool in Ubuntu 18.04
wget https://github.com/returntocorp/semgrep/releases/download/v0.15.0/semgrep-v0.15.0-ubuntu-generic.sh
chmod +x semgrep-v0.15.0-ubuntu-generic.sh
./semgrep-v0.15.0-ubuntu-generic.sh
@Matrix7867
Matrix7867 / termination-script-gcp.sh
Created February 13, 2020 09:18
terminate-gcp-instance-based-on-file-exists-or-not
echo "Termination of Instance process will start now"
curl -s http://metadata.google.internal/computeMetadata/v1/instance/name -H "Metadata-Flavor: Google" > /home/ubuntu/a
touch /home/ubuntu/_SUCCESS
filey="/home/ubuntu/_SUCCESS"
if [ -f "$filey" ]; then
cat /home/ubuntu/a | xargs -I {} gcloud compute instances delete {} --zone=us-central1-a --delete-disks=all --quiet
echo "Instance will get terminated"
else
cat /home/ubuntu/a | xargs -I {} gcloud compute instances stop {} --zone=us-central1-a --quiet
echo "Instance will gonna stop"
@Matrix7867
Matrix7867 / metadata-gcp-instance-hostname
Created February 5, 2020 06:47
Getting hostname from GCP instance via curl into metadata
#Getting hostname of the instance via Metadata
curl http://metadata.google.internal/computeMetadata/v1/instance/hostname -H "Metadata-Flavor: Google"
#Getting ID of the instance
curl http://metadata.google.internal/computeMetadata/v1/instance/id -H "Metadata-Flavor: Google"
#Getting Instance-name via Metadata
curl http://metadata.google.internal/computeMetadata/v1/instance/name -H "Metadata-Flavor: Google"
@Matrix7867
Matrix7867 / uploading-app-logs-to-s3
Created September 13, 2019 07:45
bash script to upload on S3
#!/bin/bash
logdirect="/dataa/app-service-1.0-SNAPSHOT/"
cd $logdirect
ls | grep ".log.gz" | awk '{print $1}' | head -n -3 | xargs -I {} aws s3 mv {} s3://cass-doc/app-logs/
@Matrix7867
Matrix7867 / docker-rm-stop
Last active July 30, 2019 10:40
remove all stopped/exited containers
sudo docker ps -a | grep "Exited" | sudo xargs docker rm