{ "cells": [ { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "bash\n" ] } ], "source": [ "IN=\"/bin/bash\"\n", "arrIN=${IN##*/}\n", "echo $arrIN" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "> [bla@some.com]\n", "> [john@home.com]\n", "> [Full Name ]\n" ] } ], "source": [ "var=\"bla@some.com;john@home.com;Full Name \"\n", "while [ \"$var\" ] ;do\n", " iter=${var%%;*}\n", " echo \"> [$iter]\"\n", " [ \"$var\" = \"$iter\" ] && \\\n", " var='' || \\\n", " var=\"${var#*;}\"\n", " done" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "bla@some.com john@home.com\n", "bla@some.com\n", "john@home.com\n" ] } ], "source": [ "IN=\"bla@some.com;john@home.com\" \n", "set -- \"$IN\" \n", "IFS=\";\"; declare -a Array=($*) \n", "echo \"${Array[@]}\" \n", "echo \"${Array[0]}\" \n", "echo \"${Array[1]}\"" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "latest\n" ] } ], "source": [ "tag=''\n", "if [ \"$tag\" = \"\" ]; then\n", " tag=\"latest\"\n", "fi\n", "echo $tag" ] } ], "metadata": { "kernelspec": { "display_name": "Bash", "language": "bash", "name": "bash" }, "language_info": { "codemirror_mode": "shell", "file_extension": ".sh", "mimetype": "text/x-sh", "name": "bash" } }, "nbformat": 4, "nbformat_minor": 2 }