!/bin/bash
SOURCE=./ # all of the items in the current directory
for file in $SOURCE
do
if [ -f "$file" ] ;
then
echo $file
echo ${file%.} # extract filename before the last .
echo ${file##.} # extract after the last .
echo ${file##/} # extract after the last /
echo ""
fi
done
!/bin/bash
SOURCE=./ # all of the items in the current directory for FILE in $SOURCE do if [ -f "$FILE" ] ; then FILENAME=${FILE##/} # extract after the last / EXTENSION=${FILENAME##.} # extract after the last . echo "${FILENAME%.} - $EXTENSION" # extract filename before the last . echo "" fi
done
!/bin/bash
converts a bamboo password variable into a ssh key file
TEMPFILE=./sshkey.tmp KEYFILE=./sshkey LASTLINE="-----END RSA PRIVATE KEY-----"
remove the first line: -----BEGIN RSA PRIVATE KEY-----
echo $bamboo_sshkey_password > $TEMPFILE echo $(head -c 32 $TEMPFILE) > $KEYFILE sed -i -r 's/.{32}//' $TEMPFILE sed -i "s/$LASTLINE//g" $TEMPFILE
this gets/writes the weird newlines
while read line; do echo "$line" >> $KEYFILE; done < $TEMPFILE
for i in {1..20} do echo $(head -c 77 $TEMPFILE) >> $KEYFILE sed -i -r 's/.{77}//' $TEMPFILE done
echo $(head -c 69 $TEMPFILE) >> $KEYFILE echo $LASTLINE >> $KEYFILE chmod 400 $KEYFILE
ssh -i ./sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no bamboo@172.24.32.100 "whoami"
rm -f $TEMPFILE rm -f $KEYFILE
VARIABLE=abcdef substring=${VARIABLE:3:2} //substring of a variable
!/bin/bash
STRING="header.identifier=value" KEYWORD="header.identifier"
OLDIFS=$IFS IFS='=' for word in $STRING do echo $word if [ $word == $KEYWORD ]; then echo "FOUND" fi done IFS=$OLDIFS
source util_functions.sh //add another file with source functions
if [ id -u
!= "0" ]; then
echo "Sorry, you are not root."
exit 1
fi