String handling

shell script to input two strings and stripe out the second string from the first string either from the beginning or from the end as per the user's choice

Both your question and the way you ask it sounds very homeworky...

If you want to ask a homework question, you have a couple of options:

  1. Use the proper forum; or
  2. Use your imagination and try not to make it sound homeworky.

If it's not a homework question, at least point 2 still stands.

Hello.......

Sorry to say that if these would be homework questions...then in previously asked questions i would not send my codes and ask to debug or correct......
i would straight away post the question......string handling problem i didn't understood...so i post my problem....

Hi,

Didn't understand the second part of the question i.e. to search from the beginning or end. Can you please demonstrate with an example?

Does the below code help?

#!/usr/bin/sh

echo "Enter the first string: \c"
read t
echo "Enter the search string to strip: \c"
read u

echo $t | sed "s/\(.*\)\($u\)\(.*\)/\1\3/g"
exit;