Shell Code Samples


Shell Script to Generate the SSH key and display it on output screen also create virtualenv
sandeep | 1 year, 2 months
export PATH=$WORKSPACE/resources/chromedriver/mac:$WORKSPACE/venv/bin:/usr/local/bin:$PATH
export P
shell auto ssh key
Shell Script to Monitor Site with Json content
sandeep | 1 year, 2 months
a=`curl --insecure -I SITE-NAME | awk 'NR==1 {print $2}'`
b=`wget -qO- --no-check-certificate SITEN
shell Site-Monitor
Run shell files in javascript
harika | 1 year, 2 months
//JS Code
function runShellScript(){
    const process = require('child_process'); 
keep the function code inside the js file wherever you want to use. and keep the shell file provided
javascript shell node js
copy a file and replace with another or original file
kishore_kumar | 9 months, 1 week
# way1

cp -f /path/to/file1.txt /another/path/to/file1.txt
To delete all the none docker images in single shot.
ashokrebel007 | 6 months, 2 weeks
docker rmi $(docker images | grep "^<none>" | awk "{print $3}") --force
shell docker
Remote copying (One centos machine to another centos machine)
ashokrebel007 | 6 months, 2 weeks
scp filename username@ipaddress:destinationpath

For example :
shell centos
Rename or change git branch name
kishore_kumar | 7 months
git branch -m <old-name> <new-name>
git push origin :<old-name> <new-name>
git shell
How to check the logs around or at particular time in git
harika | 3 months, 1 week
#If you want to check the logs since 1 hour
git log --since="1 hour ago"

git shell
How to untrack/ unstage a file i.e already trackable by git
harika | 3 months, 1 week
git reset HEAD fileName.txt
git shell
Return a string from shell function
harika | 6 months, 2 weeks

string shell