How do you store, and later execute, a command with redirection and and a pipe? (And is it the pipe, or the redirection, or both, that's causing my problem?)I tried to print the urxvt version in a script, as well as echo the actual command.The command I use to get the version is urxvt -help 2>&1 | head -n 2 - for some reason, urxvt prints help to stderr; as for the head, only the two first rows contain version and configuration data.In the shell, it works great, but, in the script (isolated the problem, below), it seems the third line loses its head:#!/bin/bashVER_URXVT='urxvt -help 2>&1 | head -n 2'echo $VER_URXVT$VER_URXVT
store and execute redirection/piped command in script
shell;scripting;io redirection;pipe
You need to use the eval expression#!/bin/bashVER_URXVT='urxvt -help 2>&1 | head -n 2'echo $VER_URXVTeval $VER_URXVTFrom the man page eval           The  args  are read and concatenated together into a single com-          mand.  This command is then read and executed by the shell,  and          its  exit status is returned as the value of eval.  If there are          no args, or only null arguments, eval returns 0.