Skip to content

Instantly share code, notes, and snippets.

@itsreallynick
Created June 29, 2015 15:02
Show Gist options
  • Save itsreallynick/54c84ec8a4e4cb4e9bc7 to your computer and use it in GitHub Desktop.
Save itsreallynick/54c84ec8a4e4cb4e9bc7 to your computer and use it in GitHub Desktop.
Network Analysis Scripts
#!/bin/bash
# USAGE: ./longestSubstring.sh 'abcdefghi' 'abcdeghi'
word1="$1"
word2="$2"
if [ ${#word1} -lt ${#word2} ]
then
word1="$2"
word2="$1"
fi
for ((i=${#word2}; i>0; i--)); do
for ((j=0; j<=${#word2}-i; j++)); do
if [[ $word1 =~ ${word2:j:i} ]]
then
echo ${word2:j:i}
exit
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment