UNIX/コマンド/シェル・シェル組み込み/eval


Table of Contents
% eval cd /

% set x='ls -d $HOME' (csh, tcsh の場合)
% $x
ls: $HOME: No such file or directory

% eval $x
/home/student/s1080134
#!/bin/bash
num=1
while [ $num -le $# ] ; do
   eval echo "Argument $num is \$$num"
   num=`expr $num + 1`
done	
eval echo "Argument $num is \$$num"
echo "Argument 1 is $1"
% bash [このシェルスクリプトファイル] a b c

Argument 1 is a
Argument 2 is b
Argument 3 is c
find -exec echo "コマンド ;" \;
eval `find -exec echo "コマンド ;" \;`

echo "コマンド ;"
ls [file1]
ls [file2]
ls [file3]
eval `find -exec echo "ls {}" \;`
ls [file1] ls [file2] ls [file3]
eval `find -exec echo "ls {}; " \;`
ls [file1]; ls [file2]; ls [file3]
% eval `find -exec echo "sed 's/[regexp]/[string]/g' {} > /tmp/tmp; \mv /tmp/tmp {};" \;`

% eval echo 'ls -d \$HOME'
ls -d /home/student/1080134


xrea