09-26-06 06:22 PM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
wonkim wrote:
> hi,
>
> I want to know what this bash script part means.
>
> if [ ! $FLIST -ef $WDIR/file.list ]; then
> cp $FLIST $WDIR/file.list
> fi
>
> $FLIST contains file name string list.
> $WDIR is a temporary folder name that was creadted from previous
> command.
> I can't understand what [ ! $FLIST -ef $WDIR/file.list ] condition
> means.
The square brackets invoke a logic test (either a link to the test(1)
binary, or the builtin condition test in your shell), so the condition
is performing an extended logical test of some conditions
! means negate the results of the test, so that TRUE becomes FALSE and
FALSE becomes TRUE.
<some_file> -ef <some_other_file> compares the two files and returns
TRUE if both files have the same device and inode number (in other
words, they are the same file or are hardlinks to the same file)
$FLIST is a shell variable. You've told us that it contains a filename
$WDIR is another shell variable. You've told us that it contains a
directoryname
Put this all togther, and
[ ! $FLIST -ef $WDIR/file.list ]
means
return a FALSE condition if the two paths point to the /same/ file,
otherwise return TRUE (if they point to /different/ files)
You /really/ need to read the manpage on your shell (i.e. bash(1) ) and
on the test(1) comand.
HTH
- --
Lew Pitcher
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (MingW32) - WinPT 0.11.12
iD8DBQFFGSFbagVFX4UWr64RAhznAKCR7sjahvy7
PIb8DgaojLleF+yuLwCdHPTn
+Lh2+3j0EIAJnr1E5MTyuzM=
=L25z
-----END PGP SIGNATURE-----
[ Post a follow-up to this message ]
|