Re: [ast-users] Raw command substitution $()
Can you exclude any character from your input data to be used as a separator? Then you could redefine the read separator (in the example below I used X): printf \n\n\n\n\n | IFS= read -dX FOO Date: Mon, 16 Dec 2013 21:02:01 + From: eschulm...@bloomberg.net To: AST-USERS@LISTS.RESEARCH.ATT.COM Subject: [ast-users] Raw command substitution $() Hi guys,I'm looking for a method to do raw command substitution. The issue:- Need a ksh93t+ / ksh93u facillity to be able to take the literal output of a command with no substitutions or omissions, where the substitute data is less than 1kB. Target platforms are RHEL 6.4, Solaris 11 AIX 7.1. Examples. printf is used below for illustration only.- $(), command substitution, i.e. FOO=$(printf \n\n\n\n\n); seems unsuitable as it modifies the output by performing some whitespace handling, such as stripping newlines. In this example, FOO returns zero-length.- $(), quoted, prevents the field splitting and pathname expansions, but doesn't protect the trailing whitespace.- Binary read, i.e. printf \n\n\n\n\n | read -N$length FOO; works provided the $length of the read doesn't encounter the EOF, in this case values 1-5. If $length5, in this example, FOO becomes zero-length. For an input of unknown length, this feels impractical.- One possible workaround is adding a suffix and then chopping it, i.e. FOO=$(printf \n\n\n\n\nmysuffix); FOO=${FOO%mysuffix} Any advice on the best way to acquire the literal command output? Thanks!-G ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
Re: [ast-users] Raw command substitution $()
Very usable. That looks like a winner. Thanks! -G - Original Message - From: janis_papanag...@hotmail.com To: Eugene Schulman (BLOOMBERG/ 120 PARK), ast-users@lists.research.att.com At: Dec 16 2013 16:28:54 Can you exclude any character from your input data to be used as a separator? Then you could redefine the read separator (in the example below I used X): printf \n\n\n\n\n | IFS= read -dX FOO Date: Mon, 16 Dec 2013 21:02:01 + From: eschulm...@bloomberg.net To: AST-USERS@LISTS.RESEARCH.ATT.COM Subject: [ast-users] Raw command substitution $() Hi guys, I'm looking for a method to do raw command substitution. The issue: - Need a ksh93t+ / ksh93u facillity to be able to take the literal output of a command with no substitutions or omissions, where the substitute data is less than 1kB. Target platforms are RHEL 6.4, Solaris 11 AIX 7.1. Examples. printf is used below for illustration only. - $(), command substitution, i.e. FOO=$(printf \n\n\n\n\n); seems unsuitable as it modifies the output by performing some whitespace handling, such as stripping newlines. In this example, FOO returns zero-length. - $(), quoted, prevents the field splitting and pathname expansions, but doesn't protect the trailing whitespace. - Binary read, i.e. printf \n\n\n\n\n | read -N$length FOO; works provided the $length of the read doesn't encounter the EOF, in this case values 1-5. If $length5, in this example, FOO becomes zero-length. For an input of unknown length, this feels impractical. - One possible workaround is adding a suffix and then chopping it, i.e. FOO=$(printf \n\n\n\n\nmysuffix); FOO=${FOO%mysuffix} Any advice on the best way to acquire the literal command output? Thanks!-G ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
Re: [ast-users] Raw command substitution $()
On 12/16/2013 1:02 PM, Eugene Schulman (BLOOMBERG/ 120 PARK) wrote: Hi guys, I'm looking for a method to do raw command substitution. The issue: - Need a ksh93t+ / ksh93u facillity to be able to take the literal output of a command with no substitutions or omissions, where the substitute data is less than 1kB. Target platforms are RHEL 6.4, Solaris 11 AIX 7.1. Examples. printf is used below for illustration only. - $(), command substitution, i.e. FOO=$(printf \n\n\n\n\n); seems unsuitable as it modifies the output by performing some whitespace handling, such as stripping newlines. In this example, FOO returns zero-length. - $(), quoted, prevents the field splitting and pathname expansions, but doesn't protect the trailing whitespace. - Binary read, i.e. printf \n\n\n\n\n | read -N$length FOO; works provided the $length of the read doesn't encounter the EOF, in this case values 1-5. If $length5, in this example, FOO becomes zero-length. For an input of unknown length, this feels impractical. - One possible workaround is adding a suffix and then chopping it, i.e. FOO=$(printf \n\n\n\n\nmysuffix); FOO=${FOO%mysuffix} The possible workaround is the normal approach, in my experience the mysuffix is often just a single period or lower case x. FOO=$(printf \n\n\n ; printf x ;) ; FOO=${FOO%x} You can use 'echo x' rather than 'printf x' as the trailing newline that echo produces will be removed by the command substitution. ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users