newbit: what this bash script means?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Shell > newbit: what this bash script means?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    newbit: what this bash script means?  
wonkim


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-26-06 12:32 PM

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.

Thanks!






[ Post a follow-up to this message ]



    Re: newbit: what this bash script means?  
Lew Pitcher


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
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 ]



    Sponsored Links  




 





   All times are GMT. The time now is 03:11 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register