Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!hao!noao!hsi!cjsa!jeff From: jeff@cjsa.UUCP (C. Jeffery Small) Newsgroups: comp.unix.wizards Subject: embedded newlines in shell variable? Message-ID: <228@cjsa.UUCP> Date: Mon, 10-Aug-87 13:33:44 EDT Article-I.D.: cjsa.228 Posted: Mon Aug 10 13:33:44 1987 Date-Received: Thu, 13-Aug-87 07:16:36 EDT Organization: C. Jeffery Small and Associates - New Haven, CT Lines: 38 Keywords: sed sh shell I have been attempting to construct a 'sed' command line script and load it into a shell variable (called ACTION) for later use within a bourne shell script. All goes well until I need sed to append new text to the end of the input data. To work, sed's append command ( a\ ) requires newlines to be embedded as follows: '$a\ NEW LINE OF MATERIAL' What follows is an example of what I am attempting to achieve: Match last line ------++-----Append text || vv ACTION=" -e '\$a\\nNEW LINE OF MATERIAL'" ... sed ${ACTION} $1 My experience has been that using '\n' in the assignment get the newline into the variable so that echo $ACTION prints correctly, but sed will not interpret the '\n' sequence properly. On the other hand, attempting to embed actual newlines (^J) within the assignment (ie. ACTION="-e '\$a\^JNEW LINE OF MATERIAL'") does not work since the shell substitutes the ^J with a single space. I have tried to escape every character in sight and even attempted an eval on $ACTION under various modes of construction, without success. I'm guessing that there is a simple (and obvious) trick for doing what I want. Any pointers would be greatly appreciated. Thanks in advance. ---- Jeffery Small (203) 776-2000 UUCP: ihnp4!---\ C. Jeffery Small and Associates hsi!cjsa!jeff 123 York Street, New Haven, CT 06511 hao!noao!---/