UNIX commands question

if [[ "$(echo ${dest#build.} | cut -f2 -d.)" != "S55555" ]]
then
rm -rf
 

Can anyone tell me what are they checking in the if loop

It compares the value of the variable 'dest', of which the 2nd field been cuted off, and if it is NOT S55555, then remove something the has not been copied into the post.....

However, i dont know what ${dest#build.} does as substitution (or if it is valid).

Hope this helps

The section ${dest#build.} will evaluate to the string value of $dest with any leading build. removed, so:-

$ dest=build.myfile
$ echo ${dest#build.}
myfile
$ dest=hello.myfile
$ echo ${dest#build.}
hello.myfile

I hope that this helps,
Robin

1 Like