-1
{ lineno1=`grep 'CustCare_CR*' /Abhi_data/Copy_test_demo/T2.txt`
echo $lineno1
var1=`sed -e 's#.*Backuped_CustCare/\(\)#\1#' <<< "$lineno1"`
echo $var1
path1="/CATALINA_HOME/Backuped_CustCare/$var1"
#echo $path1
cd $path1
pwd

}

When I run this code on Solaris it works, but when I run on HP-UX the <<< this operator does not work. Do you know any alternative to <<<?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Abhijeet
  • 1
  • 2
  • when i run this code on solaris then it works but when i run on shell then '<<<' this operator does not work.. Do you know any alternate to <<< this operator – Abhijeet Nov 29 '16 at 13:38
  • shell means hp unix – Abhijeet Nov 29 '16 at 13:39
  • `hpunix` is not a shell. Also, please specify which shell you have used on Solaris. In general, when writing shell scripts which are supposed to run on different platforms, you need first decide which shell you are going to use, and which version of the shell, because programming features typically vary between versions. The usual recommendation (if portability is important) is to use a POSIX shell, but with old versions of Solaris and/or HP-UX, not even the existence of this shell can be taken for granted. – user1934428 Nov 29 '16 at 16:05

2 Answers2

0

Assuming that <<< is supposed to denote a here-string, one possibility would be to pipe the word into the sed command:

 var1=`echo "$lineno1" | sed -e 's#.*Backuped_CustCare/\(\)#\1#'`
user1934428
  • 19,864
  • 7
  • 42
  • 87
0

I would recommend the printf utility, instead, along with using $() instead of `:

var1=$(printf "%s" "$lineno1" | sed -e 's#.*Backuped_CustCare/\(\)#\1#')

References:

Community
  • 1
  • 1
Jeff Schaller
  • 2,352
  • 5
  • 23
  • 38