Passing command as a function parameter

Hi All,

Just trying to implement the below shell script using AIX ksh shell.

myfunc {
     eval "$*"
}
 
CMD='ls -la /etc/hosts | awk '{print $9"|"$5}''
myfunc $CMD

Keeping getting "|}: not found" errors, any pointers would greatly be appreciated.

Kind Regards

Ed

Try:

CMD="ls -la /etc/hosts | awk '{print \$9\"|\"\$5}'"

Hi Bartus11,

Many Thanks on your assistance on this issue, that worked fine.

Kind Regards

Ed