Skip to content

Instantly share code, notes, and snippets.

@scvnc
Last active August 29, 2015 14:03
Show Gist options
  • Save scvnc/742418def384679cc065 to your computer and use it in GitHub Desktop.
Save scvnc/742418def384679cc065 to your computer and use it in GitHub Desktop.
Bash file loop screenshare sesssion tutorial
for file in *.md; do
# Execute: basename ${file} ".md"
# and store the result in name
name=$(basename ${file} ".md")
# In bash, you can refer to variables like this:
# $name or ${name}. I prefer the latter because in this
# text-crazy scripting environment it can be useful to identify
# explicitly which pieces are variables.
# Example:
# Print the contents of the variable $noun against the word 'cave'
# If noun="bat" then the result should be: batcave
# If noun="rat" then the result should be: ratcave
# echo $nouncave (will not work)
# echo ${noun}cave (works)
echo "The filename is ${file}"
echo "it's basename is ${name}"
# blank line
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment