Skip to content

Instantly share code, notes, and snippets.

@LevPewPew
Last active July 25, 2019 07:31
Show Gist options
  • Select an option

  • Save LevPewPew/82ac219766e16ffe707d3be11e965cdf to your computer and use it in GitHub Desktop.

Select an option

Save LevPewPew/82ac219766e16ffe707d3be11e965cdf to your computer and use it in GitHub Desktop.
bash scripting example 1, CodeCademy Exercise
#!/bin/bash
# script that takes all the files in the source folder,
# then reads the version of those,
# then copies all of those folders to build folder,
# unless it is secretinfo.md. it confirms with you
# the version first with yes or no (1 or 0)
echo "welcome peeps"
firstline=$(head -1 source/changelog.md)
# firstline has $ because it is already declared, the splitfirstline
# variable is currently being made therefore not being refered to
read -a splitfirstline <<< $firstline
version=${splitfirstline[1]}
echo "version: $version"
echo "would you like to change version? 1=Yes, 0=No"
read versioncontinue
if [ $versioncontinue -eq 1 ]
then
echo "OK"
for file in source/*
do
if [ "$file" == "source/secretinfo.md" ]
then
echo "$file is not being copied"
else
echo "$file"
cp $file build
fi
done
echo "copied code for version $version:"
ls build
else
echo "please come back when ready"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment