Shell Script To Concatenate Two String Given as Input including its length

by Vivek Gite [Last updated: October 20, 2008]

in Academic, Decision Making, String Management

#!/bin/bash
# Write a shell program to concatenate to two String given as input and display the
# resultant string along with its string length.
# --------------------------------------------------------------------
# This is a free shell script under GNU GPL version 2.0 or above
# Copyright (C) 2005 nixCraft project.
# Feedback/comment/suggestions : http://cyberciti.biz/fb/
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
 
STR1=$1
STR1=$2
OUT="$1$2"
if [ $# -eq 0 ]
then
	echo "$0 string1 string2"
	exit 1
fi
 
len=$(expr length $OUT)
 
echo "Concatenate string is - $OUT"
echo "String Length is - $len"
Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our email newsletter to make sure you don't miss a single tip/tricks.

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tagged as: , , , , , , , , , ,

Previous post: Shell Script To Reverse Command Line Input / Numbers

Next post: Shell Script To Find Largest Among 3 Integers (Numbers) Given As Arguments